description : It is basically used to generate runtime controls using vb.net. User has to enter number for the labels and textboxes. as soon as he click on the button. He will get that number of labels with proper formatting and alignment.
Public Class Form1 Dim ob() As Label Dim ob1() As TextBox Dim i As Integer Dim y As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Panel1.Controls.Clear() y = 10 If Val(TextBox1.Text) = Val(TextBox2.Text) Then
ReDim ob(Val(TextBox1.Text) - 1) ReDim ob1(Val(TextBox1.Text) - 1)
For i = 0 To Val(TextBox1.Text) - 1 ob(i) = New Label ob(i).Name = "lbl" & i ob(i).Text = "Test" & i ob(i).Size = New Size(50, 20) ob(i).Location = New Point(10, y) Panel1.Controls.Add(ob(i))
ob1(i) = New TextBox ob1(i).Text = "Neet " & i ob1(i).Size = New Size(150, 30) ob1(i).Location = New Point(80, y) Panel1.Controls.Add(ob1(i)) y = y + 30 'ob = Nothing 'ob1 = Nothing Next Else MsgBox("WRONG ENTRY") End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub End Class
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If Label1.Visible Then Label1.Visible = False Else Label1.Visible = True End If End Sub End Class
Regards. Neetu
AttachmentsRuntime Generation of controls in VB.NET (30741-25422-GENERATING CONTROLS.rar)
|
| Author: Miss Meetu Choudhary 25 Jul 2009 | Member Level: Diamond Points : 1 |
Please Add some description to the resource
++ Thanks and Regards. Meetu Choudhary. Site Coordinator.
|
| Author: Deepika Haridas 25 Jul 2009 | Member Level: Diamond Points : 2 |
Hi,
Don't just attach code. You must also post it. I have currently done for this post and also formatted your post. Hope from next time onwards you will take care of all these things.
--- Thanks & Regards, Deepika Editor
|