110,536
社区成员
发帖
与我相关
我的任务
分享
string[] sp = { "0", "1", "2", "3", "4" };// 比如 串口 可选列表
string[] bitraye = { "5", "6", "7", "8", "9" };// 比如 波特率 可选列表
this.comboBox1.DataSource = sp;
this.comboBox2.DataSource = bitraye;
this.comboBox1.SelectedItem = "1";// 数据库查询得出的 串口 值赋予 comboBox1
this.comboBox2.SelectedItem = "8";// 数据库查询得出的 波特率 值赋予 comboBox1
// 注册 SelectedIndexChanged 事件,两个 comboBox 的事件方法指向同一个
private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
{
string sp = (string)this.comboBox1.SelectedItem;
string bitrate = (string)this.comboBox2.SelectedItem;
// 更新数据库
}