VB.NET Technology

VB.Net Projects

VB.Net Project 1

The Button Control
Previous Home Next
adplus-dvertising

The button control exists on just about any Windows dialog you can think of. A button is primarily used to perform three kinds of tasks:

For closing a dialog with a state (for example, OK and Cancel buttons)
For performing an action on data entered on a dialog (for example clicking Search after entering some search criteria)
For opening another dialog or application (for example, Help buttons) 

Properties of Button Control

NameAvailabilityDescription
FlatStyleRead/Write If you set the style to PopUp, the button will appear flat until the user moves the mouse pointer over it. When that happens, the button pops up to its normal 3D look.
EnabledRead/WriteEnabled property to false means that the button becomes grayed out and nothing happens when you click it.
ImageRead/WriteAllow you to specify an image (bitmap, icon etc.), which will be displayed on the button.
ImageAlignRead/WriteWith this property, you can set where the image on the button should appear.
FlatStyleRead/Writedid.

Button Events

The most used event of a Button is the Click event. This occurs whenever a user clicks the button, by which we mean pressing the left mouse button and releasing it again while over the button. This means that if you left-click on the button and then draw the mouse away from the button before releasing it the Click event will not be raised. Also, the Click event is raised when the button has focus and the user press Enter. If you have a button on a form, you should always handle this event.

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = "You have clicked the button!!!"
    End Sub
End Class
Previous Home Next