Output of a method or event - C# / WPF

Asked

Viewed 159 times

2

I am using a return to be able to leave the event textEstado_Validate. The problem is that when he leaves this event, he enters the textEstado_KeyDown. How can I make sure he doesn’t enter any other method and event?

private void textEstado_Validate(object sender, ValidationEventArgs e)
{
    Ação...

    return;
}

private void textEstado_KeyDown(object sender, KeyEventArgs e)
{
    Ação...
}

There is a command for this?

textState is a Textedit, a component of Devexpress

  • What kind of textEstado?

  • A text field, edited the description

  • is the same as Textbox;

  • A "common" Textbox does not have a validation event that receives a ValidationEventArgs. @Emerson, if the class ValidationEventArgs has a property Handled, you can set it to true that the event stops being propagated.

  • I tried that way, yet he entered the other event.

1 answer

1

You can use the property Handled of ValidationEventArgs.

This will cause the event to stop propagating.

private void textEstado_Validate(object sender, ValidationEventArgs e)
{
    //Ação...

    e.Handled = true;
    return;
}

See in the documentation of ValidationEventArgs devexpress

  • I’ve tried this way @jbueno, it keeps running and enters the event textEstado_KeyDown. He enters this event because I type a character, correct?

  • The KeyDown is triggered whenever a key is clicked when the focus is on the component. I thought that way it would work, I’ll create a test project to check.

  • I appreciate any help...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.