True, if youre going as far as adding an event to all textboxs in a control and have to condition unwanted textboxs youre better off making a custom contol
and create themCode:Private Class tb Inherits TextBox Dim AllowKeys() As Char = { "1"c, "2"c, "3"c, "4", "5"c, "6"c, "7"c, "8"c, "9"c, "0"c} Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles Me.KeyPress If Not AllowKeys.Contains(e.KeyChar) Then e.Handled = True End If End Sub End Class
Code:Dim FLPTxtBoxGroup As New FlowLayoutPanel With { .FlowDirection = FlowDirection.LeftToRight, .Dock = DockStyle.Fill, .AutoScroll = True} Controls.Add(FLPTxtBoxGroup) For i As Integer = 0 To 140 Dim WonkyNumericalTextBox As New tb With { .Name = "WonkyTextBox" & i.ToString} FLPTxtBoxGroup.Controls.Add(WonkyNumericalTextBox) Next




Reply With Quote
