[c#] ListBox.SelctionMode = None이 작동하지 않는 문제의 해결

리스트 박스의 아이템을 클릭하면 파랗게 변한다. 이게 걸리적거려서 색이 변하지 않게 해야 할 때가 있는데 ListBox.DrawMode를 OwnerDrawFixed나 OwnerDrawVariable로 바꾸면 ListBox.SelectionMode = None이 되질 않고 클릭하는 거마다 다 파랗게 된다.

아래와 같이 하면 된다. 아예 새로 그려 버리는 거다.

// DrawMode = OwnerDrawFixed
// SelectionMode = None

private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
{
    e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);

    e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), e.Font, Brushes.Red, e.Bounds);
}