56

ComboBox選択したアイテムをstring変数に取得する方法を教えてもらえますか?

string selected = cmbbox.SelectedItem.ToString();
MessageBox.Show(selected);

これは私System.Data.DataRowViewの中で私を与えますMessageBox

4

4 に答える 4

96

Try this:

string selected = this.ComboBox.GetItemText(this.ComboBox.SelectedItem);
MessageBox.Show(selected);
于 2013-03-03T13:24:44.163 に答える
9

Test this

  var selected = this.ComboBox.GetItemText(this.ComboBox.SelectedItem);
  MessageBox.Show(selected);
于 2013-03-03T13:25:35.757 に答える
-3
SelectedText = this.combobox.SelectionBoxItem.ToString();
于 2016-03-10T09:04:54.353 に答える