根据列表的大小使按钮消失 [英] Making buttons disappear depending on the size of a list
问题描述
当用户填充的列表大小达到 3 个项目时,我试图让按钮从屏幕上消失.
I am trying to make a button disappear off the screen when the size of a list that is being filled by the user reaches a size of lets say 3 items.
该按钮用于添加一个新人",但是一旦列表已满,我不希望它成为将另一个人添加到列表中的选项.
The button is for "adding a new person" but once the list is full i don't want that to be an option to add another person to the list.
我尝试了以下代码,但程序没有运行
I have tried the following code but the program doesn't run
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
could someone please help me? the program doesn't even open. I just want the button to go away when the number of elements in a list is greater than a specific number lets just say 3 for now
我还可以为我的程序包含其余的代码
I can also include the rest of the code for my program
推荐答案
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
这篇关于根据列表的大小使按钮消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!