Friday, February 4, 2011

Adding a button, label, listbox, and text box programmatically

Here I added a button, label, listbox, and text box programmatically. I also changed some properties along the way.

 Public Class Form1
  
   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  
     Dim txtBox As New TextBox
  
     Dim lblLabel As New Label
  
     Dim btnButton As New Button
  
     Dim lstList As New ListBox
  
     txtBox.Height = 7
  
     txtBox.Width = 150
  
     txtBox.Text = "Hello"
  
     txtBox.Location = New Point(50, 1)
  
     lblLabel.Text = "Hola"
  
     lblLabel.Location = New Point(50, 150)
  
     btnButton.Height = 75
  
     btnButton.Width = 75
  
     btnButton.Text = "Bonjour"
  
     btnButton.Location = New Point(50, 50)
  
     lstList.Height = 70
  
     lstList.Width = 50
  
     lstList.Text = "Hi"
  
     lstList.Location = New Point(50, 175)
  
     Me.Controls.Add(txtBox)
  
     Me.Controls.Add(lblLabel)
  
     Me.Controls.Add(btnButton)
  
     Me.Controls.Add(lstList)
  
   End Sub
  
 End Class  

No comments:

Post a Comment