Control Focus question

  • Thread starter Thread starter Jason Huang
  • Start date Start date
J

Jason Huang

Hi,

I have 2 controls in my C# windows form, TextBox1 and Textbox2.
On the form load, the focus is on TextBox1.
Now I click the TextBox2.
My question is the TextBox1's LostFocus or TextBox2's GotFocus comes first?
Thanks for help.


Jason
 
Jason Huang said:
I have 2 controls in my C# windows form, TextBox1 and Textbox2.
On the form load, the focus is on TextBox1.
Now I click the TextBox2.
My question is the TextBox1's LostFocus or TextBox2's GotFocus comes
first?

Supposedly the LostFocus should come before the GotFocus, but the best way
to find the answer to this kind of question is to try it out: Write both
event handlers, and use inside them a System.Diagnostics.Debug.WriteLine
instruction to write something to the Output Window in Visual Studio. You
can then see the order of the events.
 
Back
Top