l SelectionChangeCommitted事件 在設定datasource和displaymember和valuemember時,以及手動改變combobox索引和值時都不觸發該事件, 隻是在界面選擇combobox不同值時觸發 2 SelectedIndexChanged事件 索引改變時觸發 3 SelectedValueChanged事件 值改變時觸發 設定DataSource, DisplayMember, ValueMember不同順序觸發SelectedIndexChanged事件和SelectedValueChanged事件的次數 順序一: this.comboBox1.DisplayMember = "userName"; (不觸發) this.comboBox1.ValueMember = "userAge"; (隻觸發SelectedValueChanged) this.comboBox1.DataSource = dt; (都觸發) SelectedValueChanged觸發兩次(總是先觸發)SelectedIndexChanged,觸發一次 (設定DisplayMember屬性時不觸發兩種事件) 順序二: this.comboBox1.ValueMember = "userAge"; this.comboBox1.DisplayMember = "userName"; this.comboBox1.DataSource = dt; 同上 順序三: this.comboBox1.DataSource = dt; (都觸發) this.comboBox1.DisplayMember = "userName";(都觸發) this.comboBox1.ValueMember = "userAge";(隻觸發SelectedValueChanged事件) SelectedValueChanged觸發三次(總是先觸發)SelectedIndexChanged,觸發兩次 (設定DisplayMember屬性時不觸發兩種事件) 順序四: this.comboBox1.DataSource = dt; (都觸發) this.comboBox1.ValueMember = "userAge";(都觸發) 其中SelectedValueChanged觸發兩次 this.comboBox1.DisplayMember = "userName";(都觸發) SelectedValueChanged觸發四次(總是先觸發)SelectedIndexChanged,觸發三次 (設定DisplayMember屬性時不觸發兩種事件) |