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 控件


基础教程推荐
- 将 XML 转换为通用列表 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- c# Math.Sqrt 实现 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01