如何使用SelectedIndexChanged事件为两个ComboBox使用数据库? [英] How to use Database using the SelectedIndexChanged event for the two ComboBox ?
本文介绍了如何使用SelectedIndexChanged事件为两个ComboBox使用数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有数据库。我从数据库中填写一个comboBox1。如果我选择与comboBox1相关的ComboBox2 comboBox1数据进来怎么办?你可以帮忙吗?
have database. I fill one comboBox1 from the database. What if I choose to ComboBox2 comboBox1 data associated with comboBox1 come in? Can you help please??
推荐答案
创建一个类来保存与之关联的值和值..你可以稍后检索它。
create a class to save a value and value associated with it.. and you can retrieve it later.
class ComboItem
{
public string Name;
public int ID;
public ComboItem(string Name, int value)
{
this.Name = Name;
this.ID = value;
}
public override string ToString()
{
return this.Name;
}
}
这篇关于如何使用SelectedIndexChanged事件为两个ComboBox使用数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文