// Please use the following namespace
// using System.Windows.Forms;
// using GrapeCity.Win.Editors;
public void WireKeyExitEvent()
{
GcTextBox gcTextBox1 = new GcTextBox();
// Set the maximum length limit.
gcTextBox1.MaxLength = 10;
// Move focus to next control when input chars that exceed the maximum length limit.
gcTextBox1.ExitOnLastChar = true;
gcTextBox1.KeyExit += new KeyExitEventHandler(OnTextBoxKeyExit);
}
private void OnTextBoxKeyExit(object sender, KeyExitEventArgs e)
{
if (e.Key == ExitKeys.CharInput)
{
// Validate the text of the control only when input chars that exceed the maximum length limit.
EditBase editor1 = sender as EditBase;
if (editor1 != null)
{
if (!editor1.Text.StartsWith("ID_"))
{
editor1.Clear();
}
}
}
}
' Please use the following namespace
' Imports System.Windows.Forms;
' Imports GrapeCity.Win.Editors;
Public Sub WireKeyExitEvent()
Dim gcTextBox1 As New GcTextBox()
' Set the maximum length limit.
gcTextBox1.MaxLength = 10
' Move focus to next control when input chars that exceed the maximum length limit.
gcTextBox1.ExitOnLastChar = True
AddHandler gcTextBox1.KeyExit, AddressOf OnTextBoxKeyExit
End Sub
Private Sub OnTextBoxKeyExit(ByVal sender As Object, ByVal e As KeyExitEventArgs)
If e.Key = ExitKeys.CharInput Then
' Validate the text of the control only when input chars that exceed the maximum length limit.
Dim editor1 As EditBase = TryCast(sender, EditBase)
If (Not editor1 Is Nothing) Then
If Not editor1.Text.StartsWith("ID_") Then
editor1.Clear()
End If
End If
End If
End Sub