JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Disabling Buttons

Another problem from the Testing Department concerning your program, SuperDuperTextPro. It seems the users are sometimes clicking your "Connect to the Internet" button twice by mistake, confusing the program and causing crashes. Can you stop that from happening?

Yes, you can-you can disable the button by setting its Enabled property to False when it's inappropriate to use that button. For example, we've disabled all the buttons in Figure 6.9. When a button is disabled, it is inaccessible to the user (and it can't accept the focus).


Figure 6.9: Disabling buttons in a form.

You also can disable buttons at run time, of course, like this:

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




JavaScript Editor Free JavaScript Editor     JavaScript Editor