我正在使用下面的代码来重写和绘制列表框中的每个列表项。如何将边框添加到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();
的代码是工作,我会怀疑,但是我还想添加边框列表框中的整个下拉部分(请参阅下面的示例图像。)我如何添加边框整个列表?
你在问两个问题 - 如何在下拉列表上绘制边框,以及如何修改列表中每个元素的外观?请更新您的问题以反映您的问题的性质或询问两个单独的SO问题。谢谢。 – RLH
@RLH我修改了我的问题,你会在这一个帮助.. –