开发者

Previous focused control in WinForms

开发者 https://www.devze.com 2023-01-29 16:51 出处:网络
I have a win form with lot of controls: 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 pre

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

精彩评论

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