newguy
Well-known member
Hi all, I figure out how to get my button to be created at runtime and even change the properties, now, how do I use it with a click event?
Here's the code:
Here's the code:
VB.NET:
Public Class Form1
Dim radiobutton As New RadioButton
Dim radiobutton2 As New RadioButton
Dim textbox10 As New TextBox
Dim button1 As New Button
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Select Case ListBox1.SelectedIndex
Case 0 'MCI-0
benchMarkFLP.Controls.Clear()
GroupBox1.Controls.Clear()
benchMarkFLP.Controls.Add(radiobutton)
With radiobutton
.Text = "New"
End With
benchMarkFLP.Controls.Add(radiobutton2)
With radiobutton2
.Text = "Old"
End With
GroupBox1.Controls.Add(textbox10)
With textbox10
.Multiline = True
.Dock = DockStyle.Fill
.BackColor = Color.LightBlue
.ReadOnly = True
.WordWrap = True
.Text = "HELLO"
End With
Case 1 'MCI-1
benchMarkFLP.Controls.Clear()
GroupBox1.Controls.Clear()
benchMarkFLP.Controls.Add(button1)
With button1
.Text = "Hi"
.Name = "button1"
End With
End Select
End Sub
End Class