C# checkedListBox highlight selection [Draw color]

Posts 1–4 of 4 · Page 1 of 1
C# checkedListBox highlight selection [Draw color]
I can't seem to find any help on changing the highlight color of a checkedListBox. Can anyone point me in the right direction?

The highlight is currently blue by default as seen here :
If there is no option, you must override the OnPaint event...
In the forum.designer.cs ?

Sorry i don't know much about C#, still learning
Rabir is right, you must override a draw event, try this
Code:
    public class MyCheckedListBox : CheckedListBox
    {
        public Color hColor = Color.Red;

        protected override void OnDrawItem(DrawItemEventArgs e)
        {
           if(DrawItemState.None!=e.State)
            e = new DrawItemEventArgs(e.Graphics, e.Font, e.Bounds, e.Index, DrawItemState.NoFocusRect, this.ForeColor, hColor);

            base.OnDrawItem(e);
        }
    }
And in the designer
Code:
private void InitializeComponent()
        {
            //etc....
            this.checkedListBox1 = new MyCheckedListBox();
            //etc....
        }

        private MyCheckedListBox checkedListBox1;
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?