0

我有组合框,我填写这样的数据:

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 = ???)

4

2 回答 2

2

使用SelectedValue

Mycom.SelectedValue = 33;
于 2012-05-30T06:06:54.610 回答
1

有关组合框,请参见 msdn。

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.)
于 2012-05-30T06:50:55.577 回答