BreVDD
Gebruiker
- Lid geworden
- 9 apr 2009
- Berichten
- 104
Hallo,
Ik stelde al keer een vraag over Enter.
Toen kreeg ik dat als antwoord:
Maar nu wel ik dat uitbreiden,
En wil ik ervoor zorgen dat je voor elke textbox waar er enter word getypt iets anders gebeurt...
Maar dit lukt niet, ik heb dit geprobeerd maar dit lijk niet te werken...:
Messchien ziet er iemand wat ik verkeerd doe...
Alvast bedankt
Ik stelde al keer een vraag over Enter.
Toen kreeg ik dat als antwoord:
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim TopControl As Control = DirectCast(sender, Control)
For Each c As Control In TopControl.Controls
If c.HasChildren Then
Form1_Load(c, e)
End If
If TypeOf c Is TextBox Then
If CType(c, TextBox).Multiline = False Then
AddHandler c.KeyPress, AddressOf AnyTextBox_KeyPress
End If
End If
Next
End Sub
Private Sub AnyTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
If e.KeyChar = Chr(13) Then
e.Handled = True
'Doe iets
TextBox2.BackColor = Color.AntiqueWhite
Me.TextBox1.Focus()
End If
End Sub
Maar nu wel ik dat uitbreiden,
En wil ik ervoor zorgen dat je voor elke textbox waar er enter word getypt iets anders gebeurt...
Maar dit lukt niet, ik heb dit geprobeerd maar dit lijk niet te werken...:
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim TopControl As Control = DirectCast(sender, Control)
For Each c As Control In TopControl.Controls
If c.HasChildren Then
Form1_Load(c, e)
End If
If TypeOf c Is TextBox Then
If CType(c, TextBox).Multiline = False Then
AddHandler c.KeyPress, AddressOf textbox1_KeyPress
End If
End If
Next
Dim TopControl2 As Control = DirectCast(sender, Control)
For Each c As Control In TopControl.Controls
If c.HasChildren Then
Form1_Load(c, e)
End If
If TypeOf c Is TextBox Then
If CType(c, TextBox).Multiline = False Then
AddHandler c.KeyPress, AddressOf Textbox2_KeyPress
End If
End If
Next
End Sub
Private Sub textbox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
If e.KeyChar = Chr(13) Then
e.Handled = True
'Doe iets
Me.TextBox1.Focus()
End If
End Sub
Private Sub textbox2_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
If e.KeyChar = Chr(13) Then
e.Handled = True
'Doe iets
Me.TextBox2.Focus()
End If
End Sub
Messchien ziet er iemand wat ik verkeerd doe...
Alvast bedankt
Laatst bewerkt: