Setting Focus to a .NET UserControl…?

后端 未结 7 686
不思量自难忘°
不思量自难忘° 2020-12-18 23:16

I\'m creating a custom control derived from UserControl that I would like to set focus to.

The custom control contains a ComboBox control and I draw some strings bes

7条回答
  •  隐瞒了意图╮
    2020-12-18 23:55

    In some cases it is also desireable to not let the focus move to child elements of a UserControl.
    In this case you also need to set ControlStyles.ContainerControl to false.

    Public Sub New()
        InitializeComponent()
    
        Me.SetStyle(ControlStyles.ContainerControl, False)
        Me.SetStyle(ControlStyles.Selectable, True)
    
    End Sub
    

提交回复
热议问题