Is there a way to make a UserControl unfocussable?

前端 未结 6 716
迷失自我
迷失自我 2021-01-04 11:43

Is there a way to make a UserControl unfocussable?

EDIT: So SetStyle(ControlStyles.Selectable, false)

is the way to go. But still there is diffe

6条回答
  •  耶瑟儿~
    2021-01-04 12:19

    A UserControl, or any Control, will not be able to receive focus if the CanFocus property returns false. If you look at the code in reflector it basically checks 3 properties and if any are false then it will be un-focusable.

    • IsHandleCreated
    • IsVisible
    • IsEnabled

    Setting the first two to false and having a functioning control is pretty much a contradiction. If it's possible though for your control to be functional with IsEnabled being false then that should work.

提交回复
热议问题