Click here to Skip to main content
15,893,368 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how drawimage or set background img to column header in datagridview
Posted

1 solution

Draw image on DataGridViewView Header using DataGridView's CellPainting event...

C#
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....
 
Share this answer
 
Comments
pckola 14-Aug-10 13:11pm    
Reason for my vote of 5
True

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900