每当我单击组合框内的数据/项时,它就会不断增加

时间:2019-03-02 09:18:03

标签: vb.net

在我每次运行组合框并将其添加到组合框后,将其添加到组合框后,框内的数据将自身相乘,anyhelp……这是我的代码

 Private Sub productcombobox_Click(sender As Object, e As EventArgs) Handles productcombobox.Click

        productcombobox.Items.Add("Manage Product")
        productcombobox.Items.Add("Add Product")
    End Sub

2 个答案:

答案 0 :(得分:1)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    productcombobox.Items.Add("Manage Product")
    productcombobox.Items.Add("Add Product")
End Sub

考虑已发布的评论,无需讨论。

答案 1 :(得分:0)

您只需在将数据添加到组合框中之前添加clear()方法

Private Sub productcombobox_Click(sender As Object, e As EventArgs) Handles productcombobox.Click
        productcombobox.Clear()
        productcombobox.Items.Add("Manage Product")
        productcombobox.Items.Add("Add Product")
    End Sub

这是您的代码,因此只需在其他内容之前添加Clear()方法即可。

相关问题