欲实现以下效果,请直接调用中的方法,在构造函数或者界面加载的时候调用即可
///
/// 焦点行下划线
///
///
void DrawRowLine(GridControl grid)
{
grid.Paint += (s, e) =>
{
GridView gridView = grid.FocusedView as GridView;
GridViewInfo viewinfo = gridView1.GetViewInfo() as GridViewInfo;
GridViewRects gridViewRects = viewinfo.ViewRects;
var focusedRowInfo = gridViewRects.ViewInfo.RowsInfo.GetInfoByHandle(gridView.FocusedRowHandle);
if (focusedRowInfo != null)
{
var r = focusedRowInfo.DataBounds;
Point p1 = new Point(r.X, r.Y + r.Height);
Point p2 = new Point(r.X + r.Width, r.Y + r.Height);
var pen = new Pen(Color.Yellow);
pen.Width = 2;
e.Graphics.DrawLine(pen, p1, p2);
}
};
(grid.FocusedView as GridView).FocusedRowChanged += (s, e) =>
{
grid.Refresh();
};
}
调用方法演示:
作者:涛神-Dev