我正在尝试更改 ListView 中选择栏的默认(蓝色)颜色。
我拒绝使用 ObjectListView 因为我必须更改所有代码。
我搜索过这个主题,并在这里找到了一些答案:
更改 ListView 的背景选择颜色?
但它指向 ObjectListView。
当我之前使用 ListBox 时,这可以根据我的喜好设置选择栏颜色:
OwnerDrawFixed
在“属性”下 将“绘制模式”设置为ListBox1_DrawItem
Events 下 private void ListBox1_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index < 0) return;
//if the item state is selected them 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.FromArgb(43, 144, 188));//Choose the color
// Draw the background of the ListBox control for each item. …
Run Code Online (Sandbox Code Playgroud)