Monday, February 14, 2011

Adding Buttons and labels programmatically ...

This code shows how to add textboxes and labels and set their location background color etc...

  Public Class Form1
  
 Dim lbl1, lbl2, lbl3 As New Label
  
 Dim WithEvents txt1, txt2, txt3 As New TextBox
  
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  
 lbl1.Text = "Hello"
  
 lbl1.Location = New Point(8, 163)  
 lbl2.AutoSize = true
  
 Me.Controls.Add(lbl1)
  
 lbl2.Text = "Press the reset button"
  
 lbl2.Location = (123, 5)
  
 lbl3.AutoSize = true
  
  Me.Controls.Add(lbl2)
  
 lbl3.Text = "Live life "
  
 lbl3.Location = New Point(5, 236)True
  
 txt1.Location =New Point(1, 6)
  
  txt1.Name ="txt1"
  
  Me.Controls.Add(lbl3)
  
 Me.Controls.Add(txt1)" 
  
  txt2.Location =New Point(65, 6)
  
  txt2.Name =)"txt2" 
  
  txt3.Location = New Point(124, 240) 
  
 txt3.Name ="txt3" 
  
  Me.Controls.Add(txt2)
  
 New Point(54, 166)   
  
 Me.Controls.Add(txt3) 
  
  
  
 End Sub 
  
 End Class
  

No comments:

Post a Comment