我有项目列表框....
say Listboxitem1
listboxitem2
listboxitem3...
是否可以更改listboxitem1 ...
的项目样式我看过这段代码用于更改列表框所选项目的背景颜色,但我找到了改变listboxitem项目样式的任何解决方案....
以下代码用于更改列表框中所选项目的背景颜色。但我发现任何改变项目风格的属性(如字体)
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(listbox1.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();
任何人都可以对此有所了解..
非常感谢..
答案 0 :(得分:0)