谁能告诉我如何将ComboBox的选定项转换为string变量?
ComboBox
string
string selected = cmbbox.SelectedItem.ToString(); MessageBox.Show(selected);
这将得到MessageBox中的System.Data.DataRowView
MessageBox
System.Data.DataRowView
vm0i2vca1#
试试看:
string selected = this.ComboBox.GetItemText(this.ComboBox.SelectedItem); MessageBox.Show(selected);
vyswwuz22#
您可以使用如下:
string selected = cmbbox.Text; MessageBox.Show(selected);
lb3vh1jj3#
测试this
var selected = this.ComboBox.GetItemText(this.ComboBox.SelectedItem); MessageBox.Show(selected);
eoigrqb64#
var selected = cmbbox.GetItemText(cmbbox.Text); MessageBox.Show(selected);
eagi6jfj5#
SelectedText = this.combobox.SelectionBoxItem.ToString();
5条答案
按热度按时间vm0i2vca1#
试试看:
vyswwuz22#
您可以使用如下:
lb3vh1jj3#
测试this
eoigrqb64#
eagi6jfj5#