Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 根据列表的大小使按钮消失_Vb.net_Visual Studio 2010_Visual Studio 2012 - Fatal编程技术网

Vb.net 根据列表的大小使按钮消失

Vb.net 根据列表的大小使按钮消失,vb.net,visual-studio-2010,visual-studio-2012,Vb.net,Visual Studio 2010,Visual Studio 2012,当用户填写的列表大小达到3个项目时,我试图使一个按钮从屏幕上消失 该按钮用于“添加一个新的人”,但一旦列表已满,我不希望它成为将另一个人添加到列表的选项 我尝试了下面的代码,但程序没有运行 Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove If inputNames.Count >= 3 Then 'inputnames is the name of

当用户填写的列表大小达到3个项目时,我试图使一个按钮从屏幕上消失

该按钮用于“添加一个新的人”,但一旦列表已满,我不希望它成为将另一个人添加到列表的选项

我尝试了下面的代码,但程序没有运行

Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove

    If inputNames.Count >= 3 Then   'inputnames is the name of the list
        Button1.Visible = False     'button 1 is the add a new person button
    End If
End Sub
谁能帮帮我吗?程序甚至没有打开。 我只是希望当列表中的元素数大于某个特定数时,该按钮消失,现在就说3吧


我还可以为我的程序包含其余的代码

如果您不使用listbox,则使用“list”编写适当的控件。不管怎样,他在question.Inputheight.items.count中用它的名字来称呼它似乎也不起作用。仅在键入时不会弹出items对象item@JordanH:这是因为
只是
列表框
的子属性。对于列表,它只是
。Count
。不编译吗?启动后直接崩溃?冻结?“跑”是什么意思?可能在将鼠标指针移动到窗体上后直接崩溃?使用鼠标指针首次输入时,确保
inputNames
不是
Nothing
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    If ListBox1.Items.Count >= 2 Then
        'your add code
        Button2.Visible = False
    End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    If ListBox1.Items.Count >= 2 Then
        Button2.Visible = False
    End If
End Sub