C#组合框问题 [英] C# combo Box Problem

查看:52
本文介绍了C#组合框问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我在C#中有与组合框有关的问题.
我想要的是...
我必须组合boxex.一个包含一组产品,还有另一个组合框,我希望其中的子产品将基于组合框1的选择.
我怎样才能做到这一点.
请发送验证码.我是开发人员,迫切需要它.
谢谢您

Hi all
I have problem related to combo box in C#.
What i want is...
i have to combo boxex. One contain group of products and there is another combo box where i want the sub products which will come based on the selection from combo box 1.
How can i do that.
Please send the code. I am a developer and need it urgently.
Thanking You

推荐答案

在第一个组合框的选定索引更改/值更改事件中,您将获得组合框的ID/值,根据选定的值,您可以加载您要在下一个组合框中填写的值.
On selected index changed/Value changed event of first combobox you will the id/value of the combobox,Based on the selected value you can load what ever the values you want to fill in the next combobox.


protected void cmb1_OnSelectedIndexChanged(object sender,EventArgs e)
{
    long value = Convert.Int64(cmb1.SelectedValue);
    FillCombo2(value);
}
void FillCombo2(long Combo1Value)
{
   cmb2.Items.Clear();
// fill dataset based on combo1Valuee and assign it to cmb2
    cmb2.dataSource = dt1;
    cmb2.DisplayMember ="Name";
    cmb2.ValueMember ="Id";
    cmb2.DataBind();
}



如果解决了您的问题,请标记为解决方案



Mark as solution if its solved your problem


处理 ^ ]事件,然后根据 ^ ]值.
您可以浏览给定的链接以获取更多参考信息
首次组合时自动更新组合框框获得一些价值 [ ^ ]
Handle the SelectedIndexChanged[^] event for the first ComboBox, then update the second combo box based on the SelectedItem[^] value for the first ComboBox.
You can navigate given link for more reference
Update a combo box automatically when first combo box gets some value[^]


这篇关于C#组合框问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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