TextChanged of TextBox not fired until lost focus

Answered
0
0

Please advice

TextChanged of TextBox not fired until lost focus (i have only one event suscribed: TextChanged), sample code:

private void txt_TextChanged(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(txt.Text))
{
btnFind.Enabled = true;
}
else
{
btnFind.Enabled = false;
}
}

But works if I suscribe a second event KeyPress (TextChanged event fired after KeyPress)

private void txt_KeyPress(object sender, KeyPressEventArgs e)
{

}

Please advice

Thanks in advance!

 

Using Wisej 1.3.17

  • You must to post comments
Good Answer
0
0

Hi Ser,

The TextChanged event is fired on the server when the text changes (on the server). We don’t fire it on any keystroke.

However, in order to always have the state up to date on the server, all state changes (text, size, location, selection, …) are sent back to the server with any event. For example, if you edit a field and push button, the click event data package has a leading block with all the state changes to any control that will be applied *before* the events to make sure the event code finds the right state.

That’s why when you hook up the keyboard events you also get the TextChanged event when the text changes.

HTH

Best,

Luca

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.