Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 绑定源为空_C#_Winforms - Fatal编程技术网

C# 绑定源为空

C# 绑定源为空,c#,winforms,C#,Winforms,我的数据集CafeDataSet位于项目Cafe.DataAccess中,我的winforms位于另一个项目Cafe.FrontEnd中。正在将Cafe.DataAccess编译为DLL,并将其引用添加到Cafe.FrontEnd中 我可以使用下面的代码在组合框中显示数据 comboBox1.DataSource = userTableAdapter.GetUsers(); comboBox1.DisplayMember = "Name"; comboBox1.ValueMember = "Id

我的数据集CafeDataSet位于项目Cafe.DataAccess中,我的winforms位于另一个项目Cafe.FrontEnd中。正在将Cafe.DataAccess编译为DLL,并将其引用添加到Cafe.FrontEnd中

我可以使用下面的代码在组合框中显示数据

comboBox1.DataSource = userTableAdapter.GetUsers();
comboBox1.DisplayMember = "Name";
comboBox1.ValueMember = "Id";
GetUsers是我在UserTableAdapter中创建的返回所有用户的方法

但当我试图通过添加项目数据源向导从Cafe.DataAccess将comboBox1与对象数据源CafeDataSet绑定时,它是空的


为什么??如何解决这个问题?我希望将数据集保留在单独的项目中,就像现在一样。

您仍然需要在Cafe.FrontEnd中的某个位置调用userTableAdapter.GetUsers,以填充comboBox1绑定到的CafeDataSet类型的本地数据集字段。我不确定我是否理解你所做的。您使用了BindingSource吗?

通常,如果我从“数据源”窗口拖放数据网格,我不需要编写GetUsers代码来填充datagridview。