+92 332 4229 857 99ProjectIdeas@Gmail.com

Form load event (Vb.net)


Form Load Event

Form load is an event which is fired when a form is loaded. Under this event you can specify any thing you want. You can add display a message box, you can call any function, you can set the properties of any control i.e form etc.
Below is the example, which sets the properties of the form on its load event:
AllowDrop is the property which sets whether the control can accept the data dragged by the user or not.
Opacity is the property which sets the opacity of the control.
BackColor sets the color of the back ground of the control.
MaximizeBox accepts a boolean value i.e True or False. If sets to be true then the maximize box is shown on the top right corner of the form, it sets to false inverse will happen.
ManimizeBox accepts a boolean value i.e True or False. If sets to be true then the minimize box is shown on the top right corner of the form, it sets to false inverse will happen.
Width sets the width of the form
Height sets the height of the form
TopMost accepts a boolean value i.e True or False.By setting this property to be true, the form will appear to be on top of every form, if sets to false inverse willl happen. 
FormBorderStyle sets the style of the border. The border style can be Fixed3d, Sizable, FixedSingle, FixedDialog, FixedToolWindow and SizableToolWindow and none.
StartPosition sets the start position of the form. The start position can be CenterScreen, WindowsDefaultLocation etc.
BackgroundImageLayout sets the layout of the background image.

Source code for Form Load Event in Vb.net
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 Me.AllowDrop = True  
 Me.Opacity = 0.95
 Me.BackColor = Color.White
 Me.MaximizeBox = False
 Me.MinimizeBox = True
 Me.Width = 500
 Me.Height = 500
 Me.TopMost = True
 Me.FormBorderStyle = Windows.Forms.FormBorderStyle.Fixed3D
 Me.StartPosition = FormStartPosition.CenterScreen
 Me.BackgroundImageLayout = ImageLayout.Stretch
End Sub

0 comments: