by Gehan Fernando (47 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Mon 1st October 2007
Date Added: Mon 8th February 2021
Rating: (1 Votes)
VB.NET :- Add Controls In Runtime With Control Events
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