我有comboBox,我填写这样的数据:
SQL = "select DISTINCT ActionNum,ActionName from ActionType";
adp = new SqlCeDataAdapter(SQL, Main.Conn);
adp.Fill(dsView, "ActionType");
adp.Dispose();
Mycom.DataSource = dsView.Tables[0];
Mycom.DisplayMember = dsView.Tables[0].Columns[1].ColumnName;
Mycom.ValueMember = dsView.Tables[0].Columns[0].ColumnName;
如何选择Mycom.ValueMember = 33
(类似于Mycom.SelectedIndex = ???)
答案 0 :(得分:2)
Mycom.SelectedValue = 33;
答案 1 :(得分:1)
请参阅msdn for combobox。
http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.aspx
SelectedIndex Gets or sets the index specifying the currently selected item. (Overrides ListControl.SelectedIndex.)
SelectedItem Gets or sets currently selected item in the ComboBox.
SelectedText Gets or sets the text that is selected in the editable portion of a ComboBox.
SelectedValue Gets or sets the value of the member property specified by the ValueMember property. (Inherited from ListControl.)