2009-08-10 54 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的属性到下拉