关于C#WinForm DataGridView [英] About C# WinForm DataGridView
本文介绍了关于C#WinForm DataGridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在datagridview中的列标题上绘制图像或将背景img设置为
how drawimage or set background img to column header in datagridview
推荐答案
使用DataGridView的CellPainting事件在DataGridViewView标题上绘制图像...
Draw image on DataGridViewView Header using DataGridView''s CellPainting event...
Image img = Image.FromFile(@"C:\imageName.gif");
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex==-1 ) \\you can specify column index here....
{
e.Graphics.DrawImage(img, e.CellBounds); e.Handled = true;
}
}
希望对您有帮助....
Hope it helps....
这篇关于关于C#WinForm DataGridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文