WinForms TabControl set ShowFocusCues to false?

StewartBW 1,480 Reputation points
2025-04-24T00:25:56.84+00:00

Hello,

I have difficulties hiding the focus cues around the tab page items of TabControl.

Here seems possible:

https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.tabcontrol?view=netframework-4.8

But my code won't work, anyone can help please? :)

Friend Class _TabControl
    Inherits Windows.Forms.TabControl
    Public Sub New()
        MyBase.New()
        Font = New Font("Segoe UI", 9)
    End Sub
    Protected Overrides ReadOnly Property ShowFocusCues As Boolean
        Get
            Return False
        End Get
    End Property
End Class
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,841 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 89,136 Reputation points
    2025-04-25T13:26:57.8466667+00:00

    This seems to work on my Windows 10 OS :

    Friend Class _TabControl
        Inherits Windows.Forms.TabControl
        Public Sub New()
            MyBase.New()
            Font = New Font("Segoe UI", 9)
        End Sub
        Protected Overrides ReadOnly Property ShowFocusCues As Boolean
            Get
                Return False
            End Get
        End Property
    
        Protected Overrides Sub OnHandleCreated(e As EventArgs)
            MyBase.OnHandleCreated(e)
            Me.TabStop = False
        End Sub
    End Class
    
    
      Protected Overrides Sub WndProc(ByRef m As Message)
            Const WM_UPDATEUISTATE As Integer = &H128
            Const UISF_HIDEFOCUS As Integer = &H1
            Const UIS_SET As Integer = &H1
    
            If m.Msg = WM_UPDATEUISTATE Then
                ' Force UI to always hide focus cues
                m.WParam = CType((UIS_SET Or (UISF_HIDEFOCUS << 16)), IntPtr)
            End If
    
            MyBase.WndProc(m)
        End Sub
    
    
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.