每当我点击它时,我的组合框中的数据/项目都会保持相乘

问题描述 投票:0回答:2

每当我运行它并将组合框添加到组合框中并单击组合框后,框中的数据只会繁殖自己,任何帮助...这是我的代码

 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
vb.net
2个回答
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()方法。


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

考虑到已发布的评论,不需要进行讨论。

© www.soinside.com 2019 - 2024. All rights reserved.