Well, I have managed to create controls during runtime.
Dim Rbut As New Button()
Dim Lbut As New Button()
With Rbut
.Location = New Point(590, y + 15)
.Text = "Remove"
.Name = FontName(ListBoxCount)
End With
With Lbut
.Location = New Point(590, y + 45)
.Text = "Lock"
.Name = FontName(ListBoxCount)
End With
Me.Panel1.Controls.Add(Rbut)
Me.Panel1.Controls.Add(Lbut)
AddHandler Rbut.Click, AddressOf RemButton_Click
AddHandler Lbut.Click, AddressOf LocButton_Click
Private Sub RemButton_Click(ByVal Sender As Object, ByVal e As System.EventArgs)
ListBox1.Items.Remove(Sender.Name)
End Sub
Private Sub LocButton_Click(ByVal Sender As Object, ByVal e As System.EventArgs)
ListBox1.SelectedItem = Sender.Name
End Sub
Here Rbut is Remove Button and Lbut is Lock Button. Both are created during runtime and there are maximum 10 buttons with different name from the array [FontName(ListBoxCount)]. Now, Am wondering how to disable RButton on pressing LButton.
I used RemButton_click.sender.enabled=false but in vain. Just a code snippet will make it for me. Thanks!