TextChanged event firing before the KeyXXX events

  • Thread starter Thread starter Fabrício de Novaes Kucinskis
  • Start date Start date
F

Fabrício de Novaes Kucinskis

Hi all,

I have a combobox control, in wich I put an autocomplete code. This code is
in the TextChanged event, but when this event fires, the Text property isn't
updated yet.

For example, if the Text property is "Foo" and I press the letter "d", the
Text property when the TextChanged event runs is "Foo". Only after the
TextChanged event be processed, the KeyDown, KeyUp and KeyPress events fires
and update the Text property.

I think it's very strange. Is it a bug? How can I get the correct Text
property in the TextChanged event?

Thanks in advance,


Fabrício de Novaes Kucinskis.
 
Hi,

Can you post the code you are using? I have tried this out with .NET
framework 1.0 and the Text property returns the current text in TextChanged
event. Also at my end the KeyDown event fired before the TextChanged event.
Below is the code I tried:
Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged

Console.WriteLine(TextBox1.Text)

End Sub

Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown

Console.WriteLine("fired")

End Sub

Hi all,

I have a combobox control, in wich I put an autocomplete code. This code is
in the TextChanged event, but when this event fires, the Text property isn't
updated yet.

For example, if the Text property is "Foo" and I press the letter "d", the
Text property when the TextChanged event runs is "Foo". Only after the
TextChanged event be processed, the KeyDown, KeyUp and KeyPress events fires
and update the Text property.

I think it's very strange. Is it a bug? How can I get the correct Text
property in the TextChanged event?

Thanks in advance,


Fabrício de Novaes Kucinskis.
 
Hi Herfried, Prateek,

My code is similar to the codeproject's code. I tried it (my code) in two
other computers, and it works correctly. I think the problem is my computer
(therefore I have no idea on what can do this kind of error).

I'll run the Windows Update, and try again.

Thanks for the help,


Fabrício.
 
Back
Top