How to change the background color of a rich text box when it is disabled?

后端 未结 6 873
庸人自扰
庸人自扰 2020-12-10 03:46

Whenever I set the RichTextBox.Enabled property to false, its background color is automatically set to gray as it is set to the color in system color which is s

6条回答
  •  生来不讨喜
    2020-12-10 04:16

    Create a Custom Richtextbox as below This will produce a Richtextbox with a transparent Backcolor. You can then place this control on a suitably colored panel.

    Public Class MyRichTextBox
    Inherits RichTextBox
     _
    Shared Function LoadLibrary(ByVal lpFileName As String) As IntPtr
    End Function
    Protected Overloads Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Dim prams As CreateParams = MyBase.CreateParams
            If LoadLibrary("msftedit.dll") <> IntPtr.Zero Then
                prams.ExStyle = prams.ExStyle Or &H20 'Makes Transparent
                prams.ClassName = "RICHEDIT50W"
            End If
            Return prams
        End Get
    End Property
    

提交回复
热议问题