How do you return the focus to the last used control after clicking a button in a winform app?

后端 未结 7 1250
忘掉有多难
忘掉有多难 2021-01-02 23:23

I\'m working on a windows forms application (C#) where a user is entering data in a form. At any point while editing the data in the form the user can click one of the butt

7条回答
  •  鱼传尺愫
    2021-01-02 23:50

    Create a class called CustomTextBox that inherits from TextBox. It has a static variable called stack. When the textbox loses focus push onto the stack. When you want to find the last focused control then just pop the first item from the stack. Make sure to clear the static Stack variable.

提交回复
热议问题