2013-03-03 30 views

Trả lời

48

Hãy thử điều này:

string selected = this.ComboBox.GetItemText(this.ComboBox.SelectedItem); 
MessageBox.Show(selected); 
+2

Có một lý do để thích này trong 'this.ComboBox.Text'? –

+3

@Mike E: Vâng, có một lý do. ComboBox.Text nhận hoặc đặt văn bản được liên kết với điều khiển này (không có gì chung với mục đã chọn): http://msdn.microsoft.com/de-de/library/system.windows.forms.combobox.text%28v= vs.110% 29.aspx – duDE

4

thử nghiệm this

var selected = this.ComboBox.GetItemText(this.ComboBox.SelectedItem); 
    MessageBox.Show(selected); 
+4

Có vẻ quen thuộc, câu trả lời của bạn;) – duDE

+0

Xảy ra khi được cập nhật chỉ với một khoảng thời gian một phút. –

5

Bạn có thể sử dụng như sau:

string selected = cmbbox.Text; 
MessageBox.Show(selected); 
-3
SelectedText = this.combobox.SelectionBoxItem.ToString(); 
-1

Đầu tiên thêm các mục của bạn (giúp đỡ, nope) vào bộ sưu tập của combobox thì làm như sau:

if(ComboBox1.SelectedItem == "help"){TextBox1.Text = "help";} 
if(ComboBox1.SelectedItem == "nope"){TextBox1.Text = "nope";} 
Các vấn đề liên quan