我正在尝试在 FastObjectListView 控件中绘制自定义 ColumnHeaders。
到目前为止,代码有效,但 ColumnHeaders 可用空间(因此不包含任何列标题 atm 的部分)仍然默认绘制。
private void olvMain_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Black,
e.Bounds.X, e.Bounds.Y,
e.Bounds.Width, e.Bounds.Height);
e.Graphics.DrawRectangle(Pens.Lime,
e.Bounds.X - 1, e.Bounds.Y - 1,
e.Bounds.Width - 1, e.Bounds.Height - 1);
e.DrawText();
e.DrawDefault = false;
}
我补充说:
e.DrawDefault = false;
因为没有它,columnheaders 默认样式被绘制在我的自定义样式之上,但是由于 columnheaderbar 的可用空间不包含任何 columnheaders,它仍然由它的默认样式绘制。
这是一张图片来澄清我所说的 Columnheader 的可用空间: 图片链接
提前致谢。