Visual Basic 2005


Add to MY Favorites...

Back to Vicky's Home Page Teaching Home Page Visual Basic 2005 Html For Kids

Managing Forms

Position Forms

 Properties –

            Start position options

,

 For Manual

 Enter the pixel location from the upper right corner of the screen for the location of the upper left corner of the form.

X is over

Y is down

 

Specify the Startup Object

Once you have multiple forms, you have to say which the project should open with.

  •  Pull down the Project menu. Choose the last item, My Startup Form Properties

 

  • Select the form for startup by pulling down the drop down list and clicking on the form name.  It will appear in theStartup form textbox.

 

 

Create a Form at Run Time (Using Code)

This would be useful for pop-up messages.

  • Create the form

Dim form2 as New Form

  • Put text in the title bar, set the border style

Form2.text = “New Form”

Form2.FormBorderStyle = FormBorderStyle.FixedDialog

  • Define the form position as manual

Form2StartPosition = FormStartPosition.CenterScreen

  • Display the form

Form2.ShowDialog()

Add Controls at Run Time (Using Code)

‘Declare the form and it’s control objects

Dim form2 As New Form

Dim btnCancel As New Button

Dim lblMsg As New Label

'put text on the title bar

form2.Text = "Code Created Window"

‘position the form

form2.StartPosition = FormStartPosition.CenterScreen

'add a label

lblMsg.Text = "Hello Programmer"

lblMsg.Size = New Size(150, 50)

lblMsg.Location = New Point(80, 50)

'add a button to close the window

form2.CancelButton = btnCancel

form2.Controls.Add(btnCancel)

btnCancel.Text = "Close"

btnCancel.Location = New Point(110, 100)

'add the objects to the form

form2.Controls.Add(lblMsg)

'open the form

form2.ShowDialog()

 


 
Another page developed by
vicky@vickywoodard.com
Copyright © 2006 Vicky K. Woodard
All rights reserved
Last updated: 8/17/2006