I'm having problems, trying to test an expression as the user types.
I have TreeList
where the user will enter a code, this code has the template:
- XXXX-XXXX-XXX
That is, it can be anything like:
- A216-0450-001
- X515-0477-A44
- F6FJ-0000-11C
And so it goes, so I created an event EditorKeyUp
:
treeList1.EditorKeyUp += new KeyEventHandler(this.Check_Pattern);
That triggers the Check_Pattern
method:
private void Check_Pattern()
{
TreeListNode tete = treeList1.FocusedNode;
string input = tete.GetDisplayText("Descrição").ToString();
string pattern = @"^.{4}-.{4}-.{3}$";
if (Regex.IsMatch(input, pattern))
{
MessageBox.Show("top " + input);
}
else
{
}
}
But when I type the last character, it triggers the event, but the value obtained in String Input
is the previous value.
It's as if I need to confirm the character entry.
For example: I typed A216-0450-001
the value obtained is A216-0450-00
, then when I type A216-0450-0012
it returns A216-0450-001