效果图:
给DataGridView的RowPostPaint添加事件
这个是全部行的头都画图,想要不同的图片或者不显示图则添加判断哪一行就可以了。
事件代码如下
private void RowPostPaint_Arbin(object sender, DataGridViewRowPostPaintEventArgs e)
{
try
{
Image RowIcon = Properties.Resources.Key_32x32; //图片,可以换成自己想要的
e.Graphics.DrawImage(RowIcon, e.RowBounds.Left + Convert.ToInt16(this.dgvServicesArbin.RowHeadersWidth / 2) - 4, Convert.ToInt16((e.RowBounds.Top + e.RowBounds.Bottom) / 2 - 8), 16, 16);
}
catch (Exception ex)
{
}
}