我是新手C#和使用者Windows Forms.
如截图所示,DataGridView当我点击取消按钮时,是否有人知道如何在一个选定行中水平交叉(制作十字线)?
我在网上搜索但我没有得到解决方案.
private void ButtonCancel_Click(object sender, EventArgs e)
{
}
Run Code Online (Sandbox Code Playgroud)
您可以使用RowPostPaint事件:
void dgv_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) {
if (e.RowIndex == 1) {
Rectangle r = e.RowBounds;
e.Graphics.DrawLine(Pens.DarkRed, r.Left,
r.Top + (r.Height / 2),
r.Left + r.Width,
r.Top + (r.Height / 2));
}
}
Run Code Online (Sandbox Code Playgroud)
将索引1替换为要用于绘制的行索引.