我想在Combobox中添加网格单元格值。我将如何帮助我 [英] I want to add Grid cell value in Combobox Dinamically How Will I achive this Help me

查看:64
本文介绍了我想在Combobox中添加网格单元格值。我将如何帮助我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为健身房开发项目

和计划对于健身房就像1个月,2个月,...对于健身房

如果他们有任何报价然后所有者可以添加他的自定义计划(排灯节报价)和网格中的一个复选框,用于激活计划/停用计划,当他选中此复选框,然后计划必须添加Combobox,反之亦然。

这些我有在该所有者中创建了一个计划配置表单,添加他的计划名称,计划描述,计划金额,计划多少个月,如1,2,3,4,5。

这些自定义计划我想要添加Combobox以便会员选择他的计划作为在计划配置中选择的所有者。

所以会员可以获得由所有者激活的优惠。





当加载成员窗体时,激活计划必须添加cmbobox

解决方案

如果您将数据存储在 DataTable DataSet ,您可以使用 BindingSource 来过滤掉数据哟你想要显示。

如果你将BindingSource连接到你的 ComboBox ,只会显示过滤后的数据。



示例:

  public  Form1()
{
InitializeComponent();

DataSet ds = new DataSet( 数据);
DataTable dt = ds.Tables.Add( Table1);

dt.Columns.Add( Selected typeof bool ));
dt.Columns.Add( FirstName typeof string ));
dt.Columns.Add( LastName typeof string ));

dt.Rows.Add( false Harry Hacker);
dt.Rows.Add( false Holger Aspeborn);
dt.Rows.Add( false John Doe);
dt.Rows.Add( false Jose Dela Cruz);

bindingSource1.DataSource = ds;
bindingSource1.DataMember = Table1;

bindingSource2.DataSource = ds;
bindingSource2.DataMember = Table1;
bindingSource2.Filter = Selected = true;

comboBox1.DataSource = bindingSource2;
comboBox1.DisplayMember = FirstName;
}





对于这个例子,你需要一个带有DataGridView,一个ComboBox和两个BindingSource的Windows窗体。


I am developing project for Gym
and For plan For gym is like 1 month,2 month,... for Gym
if their if any offer then owner can add his custom plan like (Diwali offer) and one check box in grid for active plan/deactivate plan when he check this checkbox then plan have to add in Combobox and wise versa.
for these i have Created a plan configuration form in that owner add his Plan name, plan description, plan amount, plan for how many months like 1,2,3,4,5.
And these Custom plan i want to add in Combobox for member to select his plan as owner selected in plan configuration.
so member can get this offer which is activate by owner.


When member windows form is loaded then Activated plan have to add in cmbobox

解决方案

If you store your data in a DataTable or DataSet, you can use a BindingSource to filter out the data you want to show.
If you connect the BindingSource to your ComboBox only the filtered data will be shown.

Example:

public Form1()
{
    InitializeComponent();

    DataSet ds = new DataSet("Data");
    DataTable dt = ds.Tables.Add("Table1");

    dt.Columns.Add("Selected", typeof(bool));
    dt.Columns.Add("FirstName", typeof(string));
    dt.Columns.Add("LastName", typeof(string));

    dt.Rows.Add(false, "Harry", "Hacker");
    dt.Rows.Add(false, "Holger", "Aspeborn");
    dt.Rows.Add(false, "John", "Doe");
    dt.Rows.Add(false, "Jose", "Dela Cruz");

    bindingSource1.DataSource = ds;
    bindingSource1.DataMember = "Table1";

    bindingSource2.DataSource = ds;
    bindingSource2.DataMember = "Table1";
    bindingSource2.Filter = "Selected = true";

    comboBox1.DataSource = bindingSource2;
    comboBox1.DisplayMember = "FirstName";
}



For this example you need to have a Windows Form with a DataGridView, a ComboBox and two BindingSource.


这篇关于我想在Combobox中添加网格单元格值。我将如何帮助我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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