2
我有我自己的自定义TextBox控件,从System.Windows.Forms.TextBox继承。我重写了OnKeyDown方法,因为如果用户按向上或向下键,我想选择上一个或下一个控件。多行文本框中的当前行
Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
MyBase.OnKeyDown(e)
If e.KeyCode = Keys.Up Then
If Not Multiline Then
Me.FindForm().SelectNextControl(Me, False, True, True, True)
Else
'TODO: If the current line is the first one, select the previous control
End If
ElseIf e.KeyCode = Keys.Down Then
If Not Multiline Then
Me.FindForm().SelectNextControl(Me, True, True, True, True)
Else
'TODO: If the current line is the last one, select the next control
End If
End If
End Sub
在多行文本框中,有什么更好的方法来知道我是否在第一行或最后一行?
非常感谢
还确保您处理关键笔划,因此它不会通过设置e.Handled = True对上下箭头键进行双重应用。 – 2009-02-11 22:42:38