Hi all,

I'm inheriting from a textbox, to amongst many other things alter the enabled behavior for a textbox in my application because "vissually impared" users can't read the grayed out text (i.o.w. sloppy users).

So I want the forecolor to stay black on the gray back color when a textbox is disabled, that's the easy part.
This is the class I'm using, but this way disabled textbox can get the focus and it's possible to select text.
how to avoid the textbox to accept focus?


Code:
Public Class TextboxPlus
    Inherits System.Windows.Forms.TextBox

    Private _enabled As Boolean = True

    Private _foreColor As System.Drawing.Color = System.Drawing.SystemColors.ControlText
    Private _backcolor As System.Drawing.Color = System.Drawing.SystemColors.Control
    Private _disabledBackcolor As System.Drawing.Color = System.Drawing.SystemColors.InactiveCaption

    Public Property DisabledBackColor As System.Drawing.Color
        Get
            Return _disabledBackcolor
        End Get
        Set(value As System.Drawing.Color)
            _disabledBackcolor = value
        End Set
    End Property

    Public Shadows Property BackColor As System.Drawing.Color
        Get
            Return If(_enabled, _backcolor, _disabledBackcolor)
        End Get
        Set(value As System.Drawing.Color)
            _backcolor = value
        End Set
    End Property

    Public Shadows Property Forecolor As System.Drawing.Color
        Get
            Return _foreColor
        End Get
        Set(value As System.Drawing.Color)
            _foreColor = value
        End Set
    End Property


    Public Shadows Property Enabled As Boolean
        Get
            Return _enabled
        End Get
        Set(value As Boolean)
            _enabled = value
            MyBase.BackColor = If(_enabled, _backcolor, _disabledBackcolor)
        End Set
    End Property

    Private Sub TextboxPlus_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown

        If Not _enabled Then
            e.Handled = True
            Exit Sub
        End If

        '---------other code---------------
    End Sub


    Private Sub TextboxPlus_KeyPress(sender As Object, e As KeyPressEventArgs) Handles Me.KeyPress

        If Not _enabled Then
            e.Handled = True
            Exit Sub
        End If

        '---------other code---------------
    End Sub


    '-------- other overrides and extra methods

    
End Class