VB.Net by API/System.Windows.Forms/Control

Материал из VB Эксперт
Перейти к: навигация, поиск

Control.Anchor

  

Imports System.Windows.Forms
public class GetControlAnchoringInformation
   public Shared Sub Main
        Application.Run(New Anchoring)
   End Sub
End class
Public Class Anchoring
    Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
    Public Sub New()
        MyBase.New()
        InitializeComponent()
        For Each ctrl As Control In Me.Controls
            Dim anchorText As New System.Text.StringBuilder
            If ctrl.Anchor And AnchorStyles.Top Then
                anchorText.Append("Top")
            End If
            If ctrl.Anchor And AnchorStyles.Left Then
                If anchorText.Length <> 0 Then
                    anchorText.Append(", ")
                End If
                anchorText.Append("Left")
            End If
            If ctrl.Anchor And AnchorStyles.Bottom Then
                If anchorText.Length <> 0 Then
                    anchorText.Append(", ")
                End If
                anchorText.Append("Bottom")
            End If
            If ctrl.Anchor And AnchorStyles.Right Then
                If anchorText.Length <> 0 Then
                    anchorText.Append(", ")
                End If
                anchorText.Append("Right")
            End If
            ctrl.Text = anchorText.ToString()
        Next
    End Sub
    "Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.IContainer
    "NOTE: The following procedure is required by the Windows Form Designer
    "It can be modified using the Windows Form Designer.  
    "Do not modify it using the code editor.
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.TextBox2 = New System.Windows.Forms.TextBox
        Me.TextBox3 = New System.Windows.Forms.TextBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.TextBox4 = New System.Windows.Forms.TextBox
        Me.SuspendLayout()
        "
        "TextBox1
        "
        Me.TextBox1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.TextBox1.Location = New System.Drawing.Point(16, 16)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(248, 20)
        Me.TextBox1.TabIndex = 0
        Me.TextBox1.Text = "Anchored to Top, Left, Right"
        "
        "TextBox2
        "
        Me.TextBox2.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.TextBox2.Location = New System.Drawing.Point(16, 72)
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.Size = New System.Drawing.Size(248, 20)
        Me.TextBox2.TabIndex = 1
        Me.TextBox2.Text = "Anchored to Top, Left, Right"
        "
        "TextBox3
        "
        Me.TextBox3.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.TextBox3.Location = New System.Drawing.Point(16, 96)
        Me.TextBox3.Multiline = True
        Me.TextBox3.Name = "TextBox3"
        Me.TextBox3.Size = New System.Drawing.Size(248, 136)
        Me.TextBox3.TabIndex = 2
        Me.TextBox3.Text = "Anchored to Top, Bottom, Left, Right"
        "
        "Button1
        "
        Me.Button1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Button1.Location = New System.Drawing.Point(168, 240)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(96, 23)
        Me.Button1.TabIndex = 3
        Me.Button1.Text = "bottom,right"
        "
        "TextBox4
        "
        Me.TextBox4.Location = New System.Drawing.Point(16, 44)
        Me.TextBox4.Name = "TextBox4"
        Me.TextBox4.Size = New System.Drawing.Size(248, 20)
        Me.TextBox4.TabIndex = 4
        Me.TextBox4.Text = "Anchored to Top, Left (default)"
        "
        "Anchoring
        "
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(280, 270)
        Me.Controls.Add(Me.TextBox4)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.TextBox3)
        Me.Controls.Add(Me.TextBox2)
        Me.Controls.Add(Me.TextBox1)
        Me.Name = "Anchoring"
        Me.Text = "Anchoring"
        Me.ResumeLayout(False)
    End Sub
#End Region
End Class


Control.BackColor

  

Imports System.Windows.Forms
Imports System.Drawing
Imports System.Drawing.Drawing2D
public class GetAllControlsOnForm
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class

Public Class Form1
    Private Sub ActRed_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ActRed.Click
        For Each scanControls As Control In Me.Controls
            If (TypeOf scanControls Is Label) Then
                scanControls.BackColor = Color.Red
            End If
        Next scanControls
    End Sub
    Private Sub ActNormal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ActNormal.Click
        For Each scanControls As Control In Me.Controls
            If (TypeOf scanControls Is Label) Then
                scanControls.BackColor = SystemColors.Control
            End If
        Next scanControls
    End Sub
End Class

<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form
    "Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.IContainer
    "NOTE: The following procedure is required by the Windows Form Designer
    "It can be modified using the Windows Form Designer.  
    "Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label
        Me.ActRed = New System.Windows.Forms.Button
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.ActNormal = New System.Windows.Forms.Button
        Me.SuspendLayout()
        "
        "Label1
        "
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(8, 8)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(39, 13)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Label1"
        "
        "ActRed
        "
        Me.ActRed.Location = New System.Drawing.Point(16, 88)
        Me.ActRed.Name = "ActRed"
        Me.ActRed.Size = New System.Drawing.Size(75, 23)
        Me.ActRed.TabIndex = 1
        Me.ActRed.Text = "Red"
        Me.ActRed.UseVisualStyleBackColor = True
        "
        "Label2
        "
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(8, 32)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(39, 13)
        Me.Label2.TabIndex = 2
        Me.Label2.Text = "Label2"
        "
        "Label3
        "
        Me.Label3.AutoSize = True
        Me.Label3.Location = New System.Drawing.Point(8, 56)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(39, 13)
        Me.Label3.TabIndex = 3
        Me.Label3.Text = "Label3"
        "
        "ActNormal
        "
        Me.ActNormal.Location = New System.Drawing.Point(104, 88)
        Me.ActNormal.Name = "ActNormal"
        Me.ActNormal.Size = New System.Drawing.Size(75, 23)
        Me.ActNormal.TabIndex = 4
        Me.ActNormal.Text = "Normal"
        Me.ActNormal.UseVisualStyleBackColor = True
        "
        "Form1
        "
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(292, 127)
        Me.Controls.Add(Me.ActNormal)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.ActRed)
        Me.Controls.Add(Me.Label1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.MaximizeBox = False
        Me.Name = "Form1"
        Me.Text = "Iterating Controls"
        Me.ResumeLayout(False)
        Me.PerformLayout()
    End Sub
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents ActRed As System.Windows.Forms.Button
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents ActNormal As System.Windows.Forms.Button
End Class


Control.Bottom

  

imports System
imports System.Drawing
imports System.Windows.Forms
public class ControlSizeLocation : inherits Form
  Private WithEvents btnShow as Button
  Private WithEvents btnChange as Button
  public sub New()
    BackColor = Color.LightBlue
    ForeColor = Color.DarkBlue
    Size = new Size(350,200)
    btnShow = new Button()
    btnShow.Location = new Point(50,50)
    btnShow.Size = new Size(100,23)
    btnShow.Text = "Show"
    btnShow.Parent = me
    btnChange = new Button()
    btnChange.Location = new Point(200,50)
    btnChange.Size = new Size(100,23)
    btnChange.Text = "Change"
    btnChange.Parent = me
  end sub
  public shared sub Main() 
    Application.Run(new ControlSizeLocation())
  end sub
  private sub btnShow_Click(ByVal sender as object,ByVal e as EventArgs) Handles btnShow.Click
    Console.WriteLine("Button Bottom:  " + btnShow.Bottom.ToString())
    Console.WriteLine("Button Top:  " + btnShow.Top.ToString())
    Console.WriteLine("Button Left:  " + btnShow.Left.ToString())
    Console.WriteLine("Button Right:  " + btnShow.Right.ToString())
    Console.WriteLine("Button Location: " + btnShow.Location.ToString())
    Console.WriteLine("Button Width:  " + btnShow.Width.ToString())
    Console.WriteLine("Button Height:  " + btnShow.Height.ToString())
    Console.WriteLine("Button Size:  " + btnShow.Size.ToString())
    Console.WriteLine("Button ClientSize:  " + btnShow.ClientSize.ToString())
    Console.WriteLine("Form Size:  " + me.Size.ToString())
    Console.WriteLine("Form ClientSize: " + me.ClientSize.ToString())
  end sub
  private sub btnChange_Click(ByVal sender as object,ByVal e as EventArgs)Handles btnChange.Click
    me.Size = new Size(800,200)
  end sub
end class


Control.Height

  


imports System
imports System.Drawing
imports System.Windows.Forms
public class ControlSizeLocation : inherits Form
  Private WithEvents btnShow as Button
  Private WithEvents btnChange as Button
  public sub New()
    BackColor = Color.LightBlue
    ForeColor = Color.DarkBlue
    Size = new Size(350,200)
    btnShow = new Button()
    btnShow.Location = new Point(50,50)
    btnShow.Size = new Size(100,23)
    btnShow.Text = "Show"
    btnShow.Parent = me
    btnChange = new Button()
    btnChange.Location = new Point(200,50)
    btnChange.Size = new Size(100,23)
    btnChange.Text = "Change"
    btnChange.Parent = me
  end sub
  public shared sub Main() 
    Application.Run(new ControlSizeLocation())
  end sub
  private sub btnShow_Click(ByVal sender as object,ByVal e as EventArgs) Handles btnShow.Click
    Console.WriteLine("Button Bottom:  " + btnShow.Bottom.ToString())
    Console.WriteLine("Button Top:  " + btnShow.Top.ToString())
    Console.WriteLine("Button Left:  " + btnShow.Left.ToString())
    Console.WriteLine("Button Right:  " + btnShow.Right.ToString())
    Console.WriteLine("Button Location: " + btnShow.Location.ToString())
    Console.WriteLine("Button Width:  " + btnShow.Width.ToString())
    Console.WriteLine("Button Height:  " + btnShow.Height.ToString())
    Console.WriteLine("Button Size:  " + btnShow.Size.ToString())
    Console.WriteLine("Button ClientSize:  " + btnShow.ClientSize.ToString())
    Console.WriteLine("Form Size:  " + me.Size.ToString())
    Console.WriteLine("Form ClientSize: " + me.ClientSize.ToString())
  end sub
  private sub btnChange_Click(ByVal sender as object,ByVal e as EventArgs)Handles btnChange.Click
    me.Size = new Size(800,200)
  end sub
end class


Control.Left

  
imports System
imports System.Drawing
imports System.Windows.Forms
public class ControlSizeLocation : inherits Form
  Private WithEvents btnShow as Button
  Private WithEvents btnChange as Button
  public sub New()
    BackColor = Color.LightBlue
    ForeColor = Color.DarkBlue
    Size = new Size(350,200)
    btnShow = new Button()
    btnShow.Location = new Point(50,50)
    btnShow.Size = new Size(100,23)
    btnShow.Text = "Show"
    btnShow.Parent = me
    btnChange = new Button()
    btnChange.Location = new Point(200,50)
    btnChange.Size = new Size(100,23)
    btnChange.Text = "Change"
    btnChange.Parent = me
  end sub
  public shared sub Main() 
    Application.Run(new ControlSizeLocation())
  end sub
  private sub btnShow_Click(ByVal sender as object,ByVal e as EventArgs) Handles btnShow.Click
    Console.WriteLine("Button Bottom:  " + btnShow.Bottom.ToString())
    Console.WriteLine("Button Top:  " + btnShow.Top.ToString())
    Console.WriteLine("Button Left:  " + btnShow.Left.ToString())
    Console.WriteLine("Button Right:  " + btnShow.Right.ToString())
    Console.WriteLine("Button Location: " + btnShow.Location.ToString())
    Console.WriteLine("Button Width:  " + btnShow.Width.ToString())
    Console.WriteLine("Button Height:  " + btnShow.Height.ToString())
    Console.WriteLine("Button Size:  " + btnShow.Size.ToString())
    Console.WriteLine("Button ClientSize:  " + btnShow.ClientSize.ToString())
    Console.WriteLine("Form Size:  " + me.Size.ToString())
    Console.WriteLine("Form ClientSize: " + me.ClientSize.ToString())
  end sub
  private sub btnChange_Click(ByVal sender as object,ByVal e as EventArgs)Handles btnChange.Click
    me.Size = new Size(800,200)
  end sub
end class


Control.Right

  
imports System
imports System.Drawing
imports System.Windows.Forms
public class ControlSizeLocation : inherits Form
  Private WithEvents btnShow as Button
  Private WithEvents btnChange as Button
  public sub New()
    BackColor = Color.LightBlue
    ForeColor = Color.DarkBlue
    Size = new Size(350,200)
    btnShow = new Button()
    btnShow.Location = new Point(50,50)
    btnShow.Size = new Size(100,23)
    btnShow.Text = "Show"
    btnShow.Parent = me
    btnChange = new Button()
    btnChange.Location = new Point(200,50)
    btnChange.Size = new Size(100,23)
    btnChange.Text = "Change"
    btnChange.Parent = me
  end sub
  public shared sub Main() 
    Application.Run(new ControlSizeLocation())
  end sub
  private sub btnShow_Click(ByVal sender as object,ByVal e as EventArgs) Handles btnShow.Click
    Console.WriteLine("Button Bottom:  " + btnShow.Bottom.ToString())
    Console.WriteLine("Button Top:  " + btnShow.Top.ToString())
    Console.WriteLine("Button Left:  " + btnShow.Left.ToString())
    Console.WriteLine("Button Right:  " + btnShow.Right.ToString())
    Console.WriteLine("Button Location: " + btnShow.Location.ToString())
    Console.WriteLine("Button Width:  " + btnShow.Width.ToString())
    Console.WriteLine("Button Height:  " + btnShow.Height.ToString())
    Console.WriteLine("Button Size:  " + btnShow.Size.ToString())
    Console.WriteLine("Button ClientSize:  " + btnShow.ClientSize.ToString())
    Console.WriteLine("Form Size:  " + me.Size.ToString())
    Console.WriteLine("Form ClientSize: " + me.ClientSize.ToString())
  end sub
  private sub btnChange_Click(ByVal sender as object,ByVal e as EventArgs)Handles btnChange.Click
    me.Size = new Size(800,200)
  end sub
end class


Control.SetBounds

  

Imports System.Windows.Forms
public class FormLayoutEvent
   public Shared Sub Main
        Application.Run(New GridForm)
   End Sub
End class
Public Class GridForm
    Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
    Public Sub New()
        MyBase.New()
        "This call is required by the Windows Form Designer.
        InitializeComponent()
        "Add any initialization after the InitializeComponent() call
    End Sub
    "Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.IContainer
    "NOTE: The following procedure is required by the Windows Form Designer
    "It can be modified using the Windows Form Designer.  
    "Do not modify it using the code editor.
    Friend WithEvents button1 As System.Windows.Forms.Button
    Friend WithEvents button2 As System.Windows.Forms.Button
    Friend WithEvents button3 As System.Windows.Forms.Button
    Friend WithEvents button4 As System.Windows.Forms.Button
    Friend WithEvents button5 As System.Windows.Forms.Button
    Friend WithEvents button6 As System.Windows.Forms.Button
    Friend WithEvents button7 As System.Windows.Forms.Button
    Friend WithEvents button8 As System.Windows.Forms.Button
    Friend WithEvents button9 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.button1 = New System.Windows.Forms.Button()
        Me.button2 = New System.Windows.Forms.Button()
        Me.button3 = New System.Windows.Forms.Button()
        Me.button4 = New System.Windows.Forms.Button()
        Me.button5 = New System.Windows.Forms.Button()
        Me.button6 = New System.Windows.Forms.Button()
        Me.button7 = New System.Windows.Forms.Button()
        Me.button8 = New System.Windows.Forms.Button()
        Me.button9 = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        "
        "button1
        "
        Me.button1.Location = New System.Drawing.Point(8, 8)
        Me.button1.Name = "button1"
        Me.button1.Size = New System.Drawing.Size(75, 75)
        Me.button1.TabIndex = 7
        Me.button1.Text = "1"
        "
        "button2
        "
        Me.button2.Location = New System.Drawing.Point(88, 8)
        Me.button2.Name = "button2"
        Me.button2.Size = New System.Drawing.Size(75, 75)
        Me.button2.TabIndex = 6
        Me.button2.Text = "2"
        "
        "button3
        "
        Me.button3.Location = New System.Drawing.Point(168, 8)
        Me.button3.Name = "button3"
        Me.button3.Size = New System.Drawing.Size(75, 75)
        Me.button3.TabIndex = 9
        Me.button3.Text = "3"
        "
        "button4
        "
        Me.button4.Location = New System.Drawing.Point(8, 88)
        Me.button4.Name = "button4"
        Me.button4.Size = New System.Drawing.Size(75, 75)
        Me.button4.TabIndex = 8
        Me.button4.Text = "4"
        "
        "button5
        "
        Me.button5.Location = New System.Drawing.Point(88, 88)
        Me.button5.Name = "button5"
        Me.button5.Size = New System.Drawing.Size(75, 75)
        Me.button5.TabIndex = 5
        Me.button5.Text = "5"
        "
        "button6
        "
        Me.button6.Location = New System.Drawing.Point(168, 88)
        Me.button6.Name = "button6"
        Me.button6.Size = New System.Drawing.Size(75, 75)
        Me.button6.TabIndex = 2
        Me.button6.Text = "6"
        "
        "button7
        "
        Me.button7.Location = New System.Drawing.Point(8, 168)
        Me.button7.Name = "button7"
        Me.button7.Size = New System.Drawing.Size(75, 75)
        Me.button7.TabIndex = 1
        Me.button7.Text = "7"
        "
        "button8
        "
        Me.button8.Location = New System.Drawing.Point(88, 168)
        Me.button8.Name = "button8"
        Me.button8.Size = New System.Drawing.Size(75, 75)
        Me.button8.TabIndex = 4
        Me.button8.Text = "8"
        "
        "button9
        "
        Me.button9.Location = New System.Drawing.Point(168, 168)
        Me.button9.Name = "button9"
        Me.button9.Size = New System.Drawing.Size(75, 75)
        Me.button9.TabIndex = 3
        Me.button9.Text = "9"
        "
        "Form1
        "
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(248, 246)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.button1, Me.button2, Me.button3, Me.button4, Me.button5, Me.button6, Me.button7, Me.button8, Me.button9})
        Me.Name = "Form1"
        Me.Text = "Grid Layout Example"
        Me.ResumeLayout(False)
    End Sub
#End Region
    Private Sub GridForm_Layout(ByVal sender As Object, ByVal e As System.Windows.Forms.LayoutEventArgs) Handles MyBase.Layout
        Dim buttons As Button() = New Button() {button1, button2, button3, button4, button5, button6, button7, button8, button9}
        Dim cx As Integer = ClientRectangle.Width / 3
        Dim cy As Integer = ClientRectangle.Height / 3
        Dim row As Integer = 0
        Do While row < 3
            Dim col As Integer = 0
            Do While col < 3
                Dim b As Button = buttons(col * 3 + row)
                b.Text = "Button"
                b.SetBounds(cx * row, cy * col, cx, cy)
                col = col + 1
            Loop
            row = row + 1
        Loop
        SetClientSizeCore(cx * 3, cy * 3)
    End Sub
End Class


Control.Top

  
imports System
imports System.Drawing
imports System.Windows.Forms
public class ControlSizeLocation : inherits Form
  Private WithEvents btnShow as Button
  Private WithEvents btnChange as Button
  public sub New()
    BackColor = Color.LightBlue
    ForeColor = Color.DarkBlue
    Size = new Size(350,200)
    btnShow = new Button()
    btnShow.Location = new Point(50,50)
    btnShow.Size = new Size(100,23)
    btnShow.Text = "Show"
    btnShow.Parent = me
    btnChange = new Button()
    btnChange.Location = new Point(200,50)
    btnChange.Size = new Size(100,23)
    btnChange.Text = "Change"
    btnChange.Parent = me
  end sub
  public shared sub Main() 
    Application.Run(new ControlSizeLocation())
  end sub
  private sub btnShow_Click(ByVal sender as object,ByVal e as EventArgs) Handles btnShow.Click
    Console.WriteLine("Button Bottom:  " + btnShow.Bottom.ToString())
    Console.WriteLine("Button Top:  " + btnShow.Top.ToString())
    Console.WriteLine("Button Left:  " + btnShow.Left.ToString())
    Console.WriteLine("Button Right:  " + btnShow.Right.ToString())
    Console.WriteLine("Button Location: " + btnShow.Location.ToString())
    Console.WriteLine("Button Width:  " + btnShow.Width.ToString())
    Console.WriteLine("Button Height:  " + btnShow.Height.ToString())
    Console.WriteLine("Button Size:  " + btnShow.Size.ToString())
    Console.WriteLine("Button ClientSize:  " + btnShow.ClientSize.ToString())
    Console.WriteLine("Form Size:  " + me.Size.ToString())
    Console.WriteLine("Form ClientSize: " + me.ClientSize.ToString())
  end sub
  private sub btnChange_Click(ByVal sender as object,ByVal e as EventArgs)Handles btnChange.Click
    me.Size = new Size(800,200)
  end sub
end class


Control.Width

  
imports System
imports System.Drawing
imports System.Windows.Forms
public class ControlSizeLocation : inherits Form
  Private WithEvents btnShow as Button
  Private WithEvents btnChange as Button
  public sub New()
    BackColor = Color.LightBlue
    ForeColor = Color.DarkBlue
    Size = new Size(350,200)
    btnShow = new Button()
    btnShow.Location = new Point(50,50)
    btnShow.Size = new Size(100,23)
    btnShow.Text = "Show"
    btnShow.Parent = me
    btnChange = new Button()
    btnChange.Location = new Point(200,50)
    btnChange.Size = new Size(100,23)
    btnChange.Text = "Change"
    btnChange.Parent = me
  end sub
  public shared sub Main() 
    Application.Run(new ControlSizeLocation())
  end sub
  private sub btnShow_Click(ByVal sender as object,ByVal e as EventArgs) Handles btnShow.Click
    Console.WriteLine("Button Bottom:  " + btnShow.Bottom.ToString())
    Console.WriteLine("Button Top:  " + btnShow.Top.ToString())
    Console.WriteLine("Button Left:  " + btnShow.Left.ToString())
    Console.WriteLine("Button Right:  " + btnShow.Right.ToString())
    Console.WriteLine("Button Location: " + btnShow.Location.ToString())
    Console.WriteLine("Button Width:  " + btnShow.Width.ToString())
    Console.WriteLine("Button Height:  " + btnShow.Height.ToString())
    Console.WriteLine("Button Size:  " + btnShow.Size.ToString())
    Console.WriteLine("Button ClientSize:  " + btnShow.ClientSize.ToString())
    Console.WriteLine("Form Size:  " + me.Size.ToString())
    Console.WriteLine("Form ClientSize: " + me.ClientSize.ToString())
  end sub
  private sub btnChange_Click(ByVal sender as object,ByVal e as EventArgs)Handles btnChange.Click
    me.Size = new Size(800,200)
  end sub
end class