来自同一数据集的多个ComboBox控件 [英] Multiple ComboBox controls from the same Dataset

查看:132
本文介绍了来自同一数据集的多个ComboBox控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows窗体上的2个DropDownList组合框,它们都是从同一个DataSet(工作人员列表)填充的,但是它们服务于不同的目的(项目经理/审核人员)。如果我将它们的数据源都设置为DataSet,则它们都绑定到DataSet并且串联更改。我缺少的东西,或者我必须读取数据集的行和列到程序集中编程而不是直接使用DataSet?或者复制DataSet?

I have 2 DropDownList combo boxes on a windows form, both populated from the same DataSet (a staff list), but they serve different purposes (project manager/reviewer). If I set the data source for both of them to the DataSet, they are both bound to the DataSet and change in tandem. 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 will 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控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆