c#GridControl如何改变单元格的边框颜色

在事件CustomDrawCell中添加

e.Cache.DrawRectangle(new Pen(Color.Red, 2), e.Bounds);

就可改变单元格边框颜色。通过Pen的设置可以设置边框颜色和边框线的大小

下面是改变第一行第一列的单元格边框颜色

private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
int columnIndex = e.Column.AbsoluteIndex;
int rowIndex = e.RowHandle;

if (columnIndex==0&&rowIndex==0)
{
e.Cache.DrawRectangle(new Pen(Color.Red, 2), e.Bounds);
}

}

猜你喜欢

转载自www.cnblogs.com/mhsl/p/9698759.html