How to change the style of a disabled control?

When a WinForm element is disabled, it looks gray. Is it possible to disable an element, but configure a disabled style so that it still looks on (not gray)?

+3
source share
2 answers

Preventing the focus control from focusing takes a number of countermeasures. You will need to enable a control that focuses on this class to resist all attempts:

using System;
using System.Windows.Forms;

class RichLabel : RichTextBox {
    public RichLabel() {
        this.ReadOnly = true;
        this.TabStop = false;
        this.SetStyle(ControlStyles.Selectable, false);
    }
    protected override void OnEnter(EventArgs e) {
        if (!DesignMode) this.Parent.SelectNextControl(this, true, true, true, true);
        base.OnEnter(e);
    }
    protected override void WndProc(ref Message m) {
        if (m.Msg < 0x201 || m.Msg > 0x20e)
            base.WndProc(ref m);
    }
}
+5
source

Windows. , , Paint , , OnPaint.

. OnPaint .

0

Source: https://habr.com/ru/post/1766796/


All Articles