Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
148 views
in Technique[技术] by (71.8m points)

vb.net - Making buttons disappear depending on the size of a list

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...