c# listBox DisplayMember
c# WinForms.Listbox.
listBox1.DataSource = ds.Tables[0].DefaultView;
listBox1.DisplayMember = "Question";
listBox1.ValueMember = "idQuestion";
//for ValueMember sh开发者_如何学运维owing...
textBox2.Text = listBox1.SelectedValue.ToString();
//What I must use for DisplayMember showing?
textbox3.Text = ??????????
That may not be so easy with untyped tables. A Combobox has a Text property, for the listbox:
textbox3.Text = listBox1.SelectedItem;
Gets you the 'item' but that probably is a DataRowView. You can cast it :
((DataRowViw) SelectedItem).Row[3]
This will work with you
textbox3.Text = listBox1.GetItemText(listBox1.SelectedItem);
精彩评论