In vb6 we could easily create an array of controls at runtime.
I need to create an array of controls at runtime in vb.net, so hoe can i do that?
Printable View
In vb6 we could easily create an array of controls at runtime.
I need to create an array of controls at runtime in vb.net, so hoe can i do that?
contorl arrays no longer exists in vb.net, but you can control events using add handler, like so....
but the following the the form load event
VB Code:
AddHandler textbox1.keypress, addressof textbox_keypress AddHandler textbox2.keypress, addressof textbox_keypress
then have a sub call
VB Code:
Private Sub textbox_keypress(ByVal sender as object, ByVal e as System.Windows.Forms.KeyPressEventArgs) If (e.KeyChar < "0" or e.KeyChar > "9") and e.KeyChar <> ChrW(8) Then e.handled = true End If End Sub
Jeff