我有一个网格,其边框自定义绘制几列。但是,当我们将自定义绘制的边界与正常(非自定义)列进行比较时,它就像是稍厚一点。因此,如果我们应用背景颜色,将像第2行第1列那样填充整个单元格。是否有任何方法可以去除此厚度,以便定制和非定制单元格应该看起来相似。自定义绘制单元格厚边框
块引用
的代码如下:
private void uxGrid_CustomDrawCell(object sender, RowcellCustomDrawEventArgs e)
{
if(col==1)
{
DrawCellBorder(b,e.bounds);
}
}
private void DrawCellBorder(RowCellCustomDrawEventArgs e, int top, int left, int right, int bottom)
{
Brush b = Brushes.Red;
if(top ==1)
e.Graphics.Fillrectangle(b, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bound.Width,1));
if(right ==1)
e.Graphics.Fillrectangle(b, new Rectangle(e.Bounds.X.Right, e.Bounds.Y, 1, e.Bound.Height));
if(bottom ==1)
e.Graphics.Fillrectangle(b, new Rectangle(e.Bounds.X, e.Bounds.Bottom, e.Bound.Width,1));
if(left ==1)
e.Graphics.Fillrectangle(b, new Rectangle(e.Bounds.X, e.Bounds.Y, 1, e.Bounds.Height));
}
我相信这个问题的原因是在你的“自定义绘制”代码。你能把这段代码追加到原来的问题吗? – DmitryG
代码更新。 – 17CrazyBrain