I would like to create events for dynamically created controls.....is this even possible?
I would like to create an event(Text_Changed for this one) for any dynamic control(in this case its a textbox).
Private WithEvents TextBox1 As New TextBox
Public Sub AddTextBoxes()
TextBox1 = New TextBox
Me.SuspendLayout()
TextBox1.CreateControl()
TextBox1.Location = New Point(296, 34) 'left/top
TextBox1.Size = New Size(71, 23) ' width/height
TextBox1.Font = New System.Drawing.Font("Microsoft Sans
Serif", 12)
TextBox1.Font = New System.Drawing.Font(TextBox1.Font,
FontStyle.Bold)
TextBox1.Name = nName '"TextBox1"
TextBox1.Text = nName 'TextBox1.Name
Controls.Add(TextBox1)
Me.ResumeLayout(True)
end sub
*************
Private Sub ???_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ???.TextChanged
End Sub
Thanks for any help.
Shane
I would like to create an event(Text_Changed for this one) for any dynamic control(in this case its a textbox).
Private WithEvents TextBox1 As New TextBox
Public Sub AddTextBoxes()
TextBox1 = New TextBox
Me.SuspendLayout()
TextBox1.CreateControl()
TextBox1.Location = New Point(296, 34) 'left/top
TextBox1.Size = New Size(71, 23) ' width/height
TextBox1.Font = New System.Drawing.Font("Microsoft Sans
Serif", 12)
TextBox1.Font = New System.Drawing.Font(TextBox1.Font,
FontStyle.Bold)
TextBox1.Name = nName '"TextBox1"
TextBox1.Text = nName 'TextBox1.Name
Controls.Add(TextBox1)
Me.ResumeLayout(True)
end sub
*************
Private Sub ???_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ???.TextChanged
End Sub
Thanks for any help.
Shane