开发者

Previous focused control in WinForms

I have a win form with lot of controls:

Previous focused control in WinForms

I want to know when user enters 'txt2' exactly after he entered 'txt1'开发者_StackOverflow. In other words when user is in 'txt2' I want to know was previous control 'txt1' or not.

What is the best way to such thing?


You could just keep a module-level variable of the type Control that stores the last control to receive focus. Since you need to keep track of each control which receives focus, each control needs to subscribe to a common event handler for the Enter event. In that event you will assign the control that has been entered to the module-level variable, but before that you can test for the jump between 'txt1' and 'txt2'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜