个人总结:
1.触发了SelectedIndexChanged事件时:comboBox1.DataSource = dt;要放在comboBox1.SelectedIndex = 0;的上面
comboBox1.DisplayMember = "hName";
comboBox1.ValueMember = "hId";
comboBox1.DataSource = dt;
comboBox1.SelectedIndex = 0;
2.触发了SelectedValueChanged事件时:comboBox1.DataSource = dt;要放在最上面
comboBox1.DataSource = dt;
comboBox1.DisplayMember = "hName";
comboBox1.ValueMember = "hId";
comboBox1.SelectedIndex = 0;
并且在 comboBox1_SelectedValueChanged事件中还要加上推断。
if (comboBox1.SelectedValue.ToString() == "System.Data.DataRowView") return;
string selectedHId = comboBox1.SelectedValue.ToString();