JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Showing and Hiding Buttons

In the last topic, we saw that we can disable buttons using the Enabled property. However, it's an inefficient use of space (and frustrating to the user) to display a lot of disabled buttons. If you have to disable several buttons, you should hide them.

To make a button disappear, just set its Visible property to False. To make it reappear, set the Visible property to True. You can set this property at either design time or run time. Here's how to make a button disappear when you click it (and probably startle the user):

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    Button1.Visible = False
End Sub

You can also use the Control class's Show and Hide methods to show and hide buttons.


If your program shows and hides buttons, you can rearrange the visible buttons to hide any gaps using the buttons' SetBounds method.

Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor