1
I’m having problems trying to test an expression as the user type.
I have a TreeList
where the user will enter a code, this code has the model:
- XXXX-XXXX-XXX
I mean, it could be anything like:
- A216-0450-001
- X515-0477-A44
- F6FJ-0000-11C
And so on, so I created an event EditorKeyUp
:
treeList1.EditorKeyUp += new KeyEventHandler(this.Check_Pattern);
That fires the method Check_Pattern
:
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 in the last character, it triggers the event, however, the value obtained in String Input
is the previous value.
It’s like I need to confirm the character input.
For example: I typed A216-0450-001
the value obtained is A216-0450-00
, there when I type A216-0450-0012
he returns A216-0450-001
I needed when the last digit was typed, in this case the character 1
, were fired the event.
Friend, I made a review, please check if it clarifies the problem.
– Thomas Erich Pimentel