D
D
Daniel2020-05-27 14:58:44
C++ / C#
Daniel, 2020-05-27 14:58:44

How to remove the selection of an item in a comboBox in blue?

How to get rid of this, and why the hell did the developers do this? If you choose FlatStyle = System , then there is no selection, but you can’t edit it, it smells like the 90s, and if you choose the more fashionable Flat, the top is a poor selection color that can only be removed with a rake.
Only without OnPaint, I already solved this problem, but there must be a normal human way? I run into this problem every time.
5ece53c006224763997271.png
And what is this event

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
d-stream, 2020-05-27
@daniil14056

Working with winforms - this is "hello from the 90s")
Therefore - just be careful like this ... squat for each sneeze:

protected override void WndProc(ref Message m)
    {
        base.WndProc(ref m);
        if (m.Msg == WM_PAINT && DropDownStyle != ComboBoxStyle.Simple)
        {
            using (var g = Graphics.FromHwnd(Handle))
            {
                using (var p = new Pen(BorderColor))
                {
                    g.DrawRectangle(p, 0, 0, Width - 1, Height - 1);

                    var d = FlatStyle == FlatStyle.Popup ? 1 : 0;
                    g.DrawLine(p, Width - buttonWidth - d,
                        0, Width - buttonWidth - d, Height);
                }
            }
        }
    }

well, or as is customary in modern times - use wpf

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question