Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically Created Controls (creating an event)

Status
Not open for further replies.

smeeks

Programmer
Oct 7, 2003
31
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top