我想問一個問題。 我在窗體中有五個按鈕和一個組合框。 組合框有5個項目可供選擇。如何在C#.Net中手動選擇組合框?
例如。
1.John
2.Steve
3.Seven
4.Jhone
5.Eistein
這樣。
我想用按鈕的事件手動選擇組合框中的項目。 當我點擊七個按鈕時,該組合框會自動選擇約翰到七。 或者選擇Eistein,組合框的選擇項目將自動選擇Seven to Eistein。 我該怎麼做?
請讓我知道你是否可以這樣做。 謝謝你的時間。 :)
我想問一個問題。 我在窗體中有五個按鈕和一個組合框。 組合框有5個項目可供選擇。如何在C#.Net中手動選擇組合框?
例如。
1.John
2.Steve
3.Seven
4.Jhone
5.Eistein
這樣。
我想用按鈕的事件手動選擇組合框中的項目。 當我點擊七個按鈕時,該組合框會自動選擇約翰到七。 或者選擇Eistein,組合框的選擇項目將自動選擇Seven to Eistein。 我該怎麼做?
請讓我知道你是否可以這樣做。 謝謝你的時間。 :)
private void einsteinButton_Click(object sender, EventArgs e)
{
int item = ComboBox.FindStringExact("Einstein");
if (item >= 0)
ComboBox.SelectedItem = item;
}
當你說
這不是我的組合框中的變化。爲什麼? – Seven
你沒在調試。爲什麼? – CodeCaster
當我調試時,我的組合框的計數是五,並沒有改變eistein.it的仍然老選擇七項。請... – Seven
「七到Eistein」你意思是你要選擇在組合框中選擇多個項目?標準組合框不支持多項選擇,因爲您需要使用ListBox控件。 –
不用理會。 我的意思是,當我點擊七個按鈕時,組合框的選定項目必須更改爲Eistein.like。 – Seven