mercredi 19 octobre 2016

Custom checkbox - disabled state color

I have a custom checkbox witch allows resizing of the main rectangle. But when I want to set it as disabled, it doesnt gray out like normal checkbox control does. It just stays white.

Here is class for custom checkbox to allow resizing:

Public Class NewCheckBox
Inherits CheckBox

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    MyBase.OnPaint(e)

    'Make the box you check 3/4 the height
    Dim boxsize As Integer = Me.Height * 0.75
    Dim rect As New Rectangle(
        New Point(0, Me.Height / 2 - boxsize / 2),
        New Size(boxsize, boxsize)
    )
    ControlPaint.DrawCheckBox(e.Graphics, rect, If(Me.Checked, ButtonState.Checked, ButtonState.Normal))
End Sub 
End Class

Here is how i want to use it:

Private Sub txtFpo_TextChanged(sender As Object, e As EventArgs) Handles txtFpo.TextChanged

    If functii.verificaLaser(txtFpo.Text) = True Then
        NewCheckBox1.Enabled = False
        'NewCheckBox1.ForeColor = Color.DarkGray
    End If

I've tried to set the forecolor property, but to no avail.

How can i make the custom control to be greyed out in disabled mode?




Aucun commentaire:

Enregistrer un commentaire