Author : Gehan Fernando
Date Submitted : 1/10/2007
Category : Forms
Compatibility : .NET
This code has been accessed 3358 times.
Task : VB.NET :- Add Controls In Runtime With Control Events
Declarations
Code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Lstbox = New ListBox()
Dim Pnt As Point = New Point(10, 10)
LstBox.Location = Pnt
Dim MSize As Size = New Size(Me.Width - 30, Me.Height - 50)
LstBox.Size = MSize
Me.Controls.Add(LstBox)
LstBox.Visible = True
For i As Integer = 1 To 100
Lstbox.Items.Add("Item Index :- " & i)
Next
End Sub
Private Sub Lstbox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Lstbox.Click
MessageBox.Show(Lstbox.SelectedItem.ToString(), "Test Data", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub