C #: How to suppress UserControl in order to focus on the first control over children?

I have a UserControl that can have child controls.

The user control has styles:

this.SetStyle(
            ControlStyles.AllPaintingInWmPaint |
            ControlStyles.OptimizedDoubleBuffer |
            ControlStyles.Selectable |
            ControlStyles.SupportsTransparentBackColor |
            ControlStyles.UserPaint,
            true);

Now, if I click on usercontrol (not a child control), I want the usercontrol to keep focus, but the focus automatically moves to the first child control. The same thing happens if I use the tab key.

i already failed to cancel OnGotFocus.

Any idea?

+3
source share
1 answer

UserControl, WM_SETFOCUS . , , WndProc() , UC .

- , UC. , Panel , . .

+3

Source: https://habr.com/ru/post/1787726/


All Articles