How to set focus to a control after validation in .NET

后端 未结 4 1562
既然无缘
既然无缘 2021-01-18 12:12

I have a WinForm application with several input controls on a form. In the validation event handler (either Validating or Validated), I need to det

4条回答
  •  既然无缘
    2021-01-18 12:46

    This thread is old, but I have a couple of thoughts:

    1. Every control has a Tag property. What about giving the control you want have focus a unique Tag value, and then create a method that will iterate through the controls to find that control? Then you can set focus to it.

    2. Instead of using the Validating event, why not use Leaving instead? Doesn't seem to have the same quirks.

提交回复
热议问题