我们绑定一个DataGridview使用BindingSource.所以在我们这样给出的主线程中.
class1BindingSource = new BindingSource();
class1BindingSource.DataSource = class1List;
this.dataGridView1.DataSource = class1BindingSource;
Run Code Online (Sandbox Code Playgroud)
之后,我在窗体中放置了一个后台工作器,并在单击按钮时触发.
即在按钮单击中
this.backgroundWorker1.RunWorkerAsync()
Run Code Online (Sandbox Code Playgroud)
在BackgroundWorker DoWork Event我试图BindingSource通过尝试更新来更新和那里DataGridview.
因此,BindingSource重置是在另一个类的方法中完成的.
DoWork Event
Class2 cl2 = new Class2();
cl2.UpdateBindingSource(class1BindingSource);
Run Code Online (Sandbox Code Playgroud)
UpdateBindingSource Method
public void UpdateBindingSource(BindingSource bs)
{
Class1 c1 = bs.Current as Class1;
for (int i = 0; i < 1000; i++)
{
lock (bs.SyncRoot)
{
c1.MyProperty1 = i;
bs.ResetItem(0);
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在我得到一个例外,就像BindingSource它不能成为自己的数据源一样.不要将DataSource和DataMember属性设置为引用的值BindingSource. …
datagridview backgroundworker thread-safety bindingsource winforms
我正在使用ServiceStack并已开始为我的服务添加基于角色的授权.从文档中我可以看到有服务通过Web服务从用户分配和删除角色.
我的问题是ServiceStack中是否包含任何内置服务来查询用户当前拥有的角色和权限?
如何listbox使用SaveFileDialog?将项目的内容保存到文本文件?
我还想在文本文件中添加其他信息,并添加MessageBox成功后保存的说法.
我无法让我的客户端在我的lindgren网络测试中连接到我的服务器.我尝试了多种连接方式,但是当我尝试连接时它总是停止.对不起,如果这是一个广泛的问题,但我做错了什么?这是我的代码:
class Program
{
static NetPeerConfiguration serverconfig;
static NetPeerConfiguration clientconfig;
static NetServer server;
static NetClient client;
static void Main()
{
Console.Title = "LidgrenNetworkTest";
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("LidgrenNetworkTest console initialized.");
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("Color codes: ");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("System ");
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("Input ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("Sent ");
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("Received");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("\n");
Console.WriteLine("Configuring server...");
serverconfig = new NetPeerConfiguration("LidgrenNetworkTest");
serverconfig.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
serverconfig.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
serverconfig.LocalAddress = NetUtility.Resolve("localhost");
serverconfig.Port = 8080;
Console.WriteLine("Server configured.");
Console.WriteLine("Configuring client...");
clientconfig = new NetPeerConfiguration("LidgrenNetworkTest"); …Run Code Online (Sandbox Code Playgroud) 我一直试图找到这个问题的答案好几天,我发现很难相信这不可能做到.
我想要在DataSet/DataTable构建页面时SqlDataSource.Select由ASP.NET运行时自动调用方法时构建.
我知道我可以在代码后面运行它,但这使得第二次访问数据库,我真的想避免这种情况.我遇到的每个例子都告诉你在后面的代码中执行Select方法.
有没有办法访问已经检索的数据?
我刚刚从JQ UI 1.8.23切换到1.10.至于这个版本,ajaxOptions不推荐使用,现在ui.ajaxSettings改为使用.
这就是我的代码的样子:
$( "#tabs" ).tabs({
ajaxOptions: {
type : 'POST',
data : 'format=html',
error: function( xhr, status, index, anchor ) {
$( anchor.hash ).html(
"Couldn't load this tab. We'll try to fix this as soon as possible. " +
"If this wouldn't be a demo. " );
},
success: function() {
*Something in here*
}
}
});
Run Code Online (Sandbox Code Playgroud)
一切都很好.现在新代码:
$( "#tabs" ).tabs({
beforeLoad: function( event, ui ) {
ui.ajaxSettings.type = 'POST'; …Run Code Online (Sandbox Code Playgroud) 我有两种形式,Form1(DGV1 & DGV2)并且两种形式Form2(DGV3 & DGV4)都有Datagridview控件.
在Form1那里有一个Form2用户可以添加行的按钮链接Form1 datagridview(DGV1).在Form2 ? (DGV3 and DGV4),checkbox第一列中有一个,用户一次只能选择一行.
有两个按钮Form2:Done和Add Items
当用户通过一个接一个地选择行来单击"添加项目"时,必须将行添加到" datagridview打开" Form1,单击"完成"按钮时,Form1应显示添加的所有行.
我做到了这一点.
列中的DGV1和DGV2是
DGV1色谱柱
Sno Desciption SellQty ItemID
----------------------------
1 ABC 0 1
2 XYZ 0 2
Run Code Online (Sandbox Code Playgroud)
DGV2色谱柱
Sno BatchNo SellQty ItemID
----------------------------
1 123 10 1
2 528 20 2
1 568 30 1
2 …Run Code Online (Sandbox Code Playgroud) 我是新手.Net Framework,我想在我的Windows窗体应用程序中添加验证Visual Studio 2010 IDE.我已经搜索了不同的方法,但我不确定在哪里可以添加我的表单中的代码?其中一个例子是下面的代码.
我是否在表单加载方法或提交按钮或其他位置添加此代码?
using System;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;
namespace MvcMovie.Models
{
public class Movie
{
public int ID { get; set; }
[Required(ErrorMessage = "Title is required")]
public string Title { get; set; }
[Required(ErrorMessage = "Date is required")]
public DateTime ReleaseDate { get; set; }
[Required(ErrorMessage = "Genre must be specified")]
public string Genre { get; set; }
[Required(ErrorMessage = "Price Required")]
[Range(1, 100, ErrorMessage = "Price must be between $1 …Run Code Online (Sandbox Code Playgroud) 我想打印我的TextBox,这是我的代码:
private void MenuItemPrint()
{
if (FileName != "")
{
PrintDocument document = new PrintDocument();
document.PrinterSettings.PrintFileName = FileName;
document.Print();
}
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用。我应该怎么办?
我有三个表一是" Allowance"," Balance"和" TimeoffRequests"在这三个表中的公共列是EmployeeId和TimeoffTypeId,现在我需要通过分组他们timeoffTypeId和EmployeeId表" TimeoffRequests"得到一个请假的一个请求时间,并得到" TimeOffHours" .因为我写的代码就像
var query = (from tr in TimeOffRequests
where tr.EmployeeID == 9
group tr by new { tr.EmployeeID, tr.TimeOffTypeID } into res
select new
{
EmployeeID = res.Key.EmployeeID,
TimeOffTypeID = res.Key.TimeOffTypeID,
TotalHours = res.Sum(x => x.TimeOffHours)
}).AsEnumerable();
Run Code Online (Sandbox Code Playgroud)

现在我需要将这些结果与第一个表联系起来,并且必须从所有员工中获取,并timeoffTypes从分组表中的UserAllowance相应TimeoffHours表中获取.为了得到左连接查询我写如下.
var requestResult = (from UA in UserAllowances
join UB in UserBalances on UA.EmployeeID equals UB.EmployeeID
where UA.TimeOffTypeID …Run Code Online (Sandbox Code Playgroud) c# ×8
winforms ×3
datagridview ×2
.net ×1
ado.net ×1
asp.net ×1
jquery ×1
jquery-ui ×1
left-join ×1
linq ×1
listbox ×1
networking ×1
post ×1
printing ×1
servicestack ×1
text-files ×1
textbox ×1