Placing Controls on Form

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This lesson explains how to add controls to a form

Visual Studio (Express 2013 for Windows Desktop) and its Windows Forms Designer are configured to be quite usable. As soon as you open the Designer you can immediately use the Toolbox to place controls on the form.

However the Windows Forms Designer allows you to add controls to a form in a several different ways.

1. First way is, if you double-click a control on the Toolbox, Visual Studio places an instance of the control on the form in a default location and at a default size. Then you can use the mouse to relocate and resize the control.

2. Second way is, if you click a control in the Toolbox, the mouse cursor changes while the mouse is over the form. The new cursor looks like a plus sign with a small image of the control's Toolbox icon next to it. If you click the form, Visual Studio adds a control at that location with a default size.


Figure 1 (with selected control in the toolbox you click the form)


Figure 2 (Visual Studio adds a control at the location you've clicked)

3. Third way is, if you do add and configure control programmatically at run time:

    Dim CheckBox1 As New CheckBox
    Me.CheckBox1.AutoSize = True
    Me.CheckBox1.Location = New System.Drawing.Point(31, 144)
    Me.CheckBox1.Name = "CheckBox1"
    Me.CheckBox1.Size = New System.Drawing.Size(94, 17)
    Me.CheckBox1.TabIndex = 4
    Me.CheckBox1.Text = "Remember me"
    Me.CheckBox1.UseVisualStyleBackColor = True
    Me.Controls.Add(CheckBox1)

Previous Lesson | Next Lesson


Share This

Subscribe

More Tutorials

Popular

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2017 - All Rights Reserved.