Я использую следующий код для переопределения и отрисовки каждого элемента списка в ListBox.
if (e.Index < 0) return;
// if the item state is selected then change the back color
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
e = new DrawItemEventArgs(e.Graphics,
e.Font,
e.Bounds,
e.Index,
e.State ^ DrawItemState.Selected,
e.ForeColor,
Color.Red); // Choose the color
// Draw the background of the ListBox control for each item.
e.DrawBackground();
// Draw the current item text
e.Graphics.DrawString(studentsListBox.Items[e.Index].ToString(), e.Font, Brushes.Black, e.Bounds, StringFormat.GenericDefault);
// If the ListBox has focus, draw a focus rectangle around the selected item.
e.DrawFocusRectangle();
Код работает так, как я подозреваю, однако я также хотел бы добавить границу для всей раскрывающейся части списка (см. Пример изображения ниже). Как добавить границу для всего списка
![enter image description here](https://i.stack.imgur.com/VN4zE.png)