ComboBox初始值未重置 [英] ComboBox initial value is not resetting

查看:110
本文介绍了ComboBox初始值未重置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我最初显示我的ComboBox时,使用该行...



When I initially display my ComboBox, using the line ...

ComboBox3.SelectedIndex = -1





...根据需要显示为空白。



然而,当我已经从ComboBox中选择然后取消,以便重置表单,ComboBox不会显示为空白但它保留我之前做出的选择。



任何想法为什么&如何将其重置为Null?



代码如下,相当基本的东西:





... it displays as blank, as required.

However, when I have made a selection from that ComboBox and then Cancelled, so as to reset the form, the ComboBox does not display as blank but it retains the selection I previously made.

Any ideas why & how I can reset it to being Null ?

The code is as follows, fairly basic stuff :

Public Sub Tab4_Selected()

    ComboBox3.Items.Clear()

    For Each Item In ComboBox1.Items
        With ComboBox3.Items
            .Add(Item)
        End With
    Next

    ComboBox3.Items.RemoveAt(0)

    ComboBox3.SelectedIndex = -1

    Button1.Visible = True
    Button2.Visible = True
    Button11.Visible = False
    Button12.Visible = False
    Button13.Visible = False
    Label4.Visible = False
    Label5.Visible = False
    Label6.Visible = False
    Label7.Visible = False
    Label8.Visible = False
    DateTimePicker1.Visible = False
    DateTimePicker2.Visible = False
    DateTimePicker3.Visible = False
    DateTimePicker4.Visible = False
    TextBox1.Visible = False

End Sub

推荐答案

我刚刚模拟了你的概率lem ...

这里,把这一行放在SelectedIndex = -1之下,不要担心,没有选择任何项目。



I have just simulated your problem...
Here, put this line below your SelectedIndex = -1 and don't worry, no item is selected.

comboBox1.SelectedIndex = -1;
comboBox1.ResetText();


这篇关于ComboBox初始值未重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆