一 通过数据绑定取值
- DataRowView drv = listbox1.SelectedItem as DataRowView;
- MessageBox.Show("text=" + drv[listbox1.DisplayMember] + ";value=" + drv[listbox1.ValueMember]);
如果是要循环
DataRowView drv = listbox1.Items[i] as DataRowView
drv[listbox1.DisplayMember]
drv[listbox1.ValueMember]
二 直接取值(只能取当前选定项的值),如果要循环,就要修改listBox1.SelectedIndex值
lisbbox1.SelectedValue;