2009-08-10 88 views

回答

1

設置0值selectedIndex屬性。它會選擇第一個列表項目。

private Sub button1_Click(sender as object,e as EventArgs) Handles button1.Click 
    comboBox1.SelectedIndex = 0 
End Sub 
+0

很抱歉,這如果vb.net Windows應用程序項目 – 2009-08-10 12:10:34

+0

我已經給出了供您參考的圖像 http://www.drivehq.com/file/df.aspx/publish/rk.babu/Files/ComboBoxReset.jpg – 2009-08-11 10:50:30

+1

列表收集的第一項必須是「選擇」。 – adatapost 2009-08-11 11:46:27

1

只需設置文本屬性:

Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged 
    If ComboBox1.SelectedIndex = -1 Then ComboBox1.Text = "Select" 
End Sub 
-1

雙擊在設計屏幕上的清除按鈕,然後鍵入下面的代碼,以清除在組合框中選擇的值。

private void button2_Click(object sender, EventArgs e) 
    { 

     c1.SelectedIndex = -1; 
    } 
+0

OP明確地說:「我曾嘗試給-1給SelectedIndex,但它只給出Empty。」 – 2012-10-01 16:55:46

2

如果ComboBox1財產 'DropDownStyle' 設置爲 '簡單' 或 '下拉' 然後

Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged 
    If ComboBox1.SelectedIndex = -1 Then ComboBox1.Text = "Select" 
End Sub 

會工作。如果設置爲「DropDownList的」再不行......

+0

謝謝你的有效答覆。 – AT07 2017-01-07 10:04:41

0

combobox1.Text =「選擇」

,並更改組合框dropdownstyle的屬性到下拉