Multiple ComboBox controls from the same Dataset(来自同一数据集的多个 ComboBox 控件)
问题描述
我在 Windows 窗体上有 2 个 DropDownList 组合框,它们都从同一个数据集(员工列表)填充,但它们用于不同的目的(项目经理/审阅者).
I have 2 DropDownList ComboBoxes on a Windows Form, both populated from the same DataSet (a staff list), but they serve different purposes (project manager/reviewer).
如果我将它们的 DataSource 都设置为 DataSet,它们都绑定到 DataSet 并同时更改.
If I set the DataSource for both of them to the DataSet, they are both bound to the DataSet and change in tandem.
我是否遗漏了什么,或者我是否必须以编程方式将数据集的行和列读入 Items 集合,而不是直接使用 DataSet?
还是复制 DataSet?
Am I missing something, or will I have to read the rows and columns of the data set into the Items collection programmatically instead of using the DataSet directly?
Or replicate the DataSet?
在另一个表单上,我多次遇到同样的问题.
On another form, I have the same problem several times.
推荐答案
在 bytes.com
combo1.DataSource = payDS.Tables[0];
combo1.BindingContext = new BindingContext();
combo1.DisplayMember = "staff_name";
combo1.ValueMember = "staff_id";
combo2.DataSource = payDS.Tables[0];
combo2.BindingContext = new BindingContext();
combo2.DisplayMember = "staff_name";
combo2.ValueMember = "staff_id";
对我有用.
这篇关于来自同一数据集的多个 ComboBox 控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:来自同一数据集的多个 ComboBox 控件


- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01