Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In C# WinForm,How to set the DataGridView column header background (Image)
Posted
Comments
Manfred Rudolf Bihy 3-Jan-11 5:47am    
Was that vote of 2 your work? If it was, may I inquire why you voted low?

In this thread they're showing some code to achieve the effect that you wish:

http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/91b38c04-feff-478a-864f-01b545888593/[^]

Please read the whole thread. It's not very long.

Regards,

Manfred
 
Share this answer
 
v2
Comments
luoyangerp 3-Jan-11 5:31am    
Thanks
Nuri Ismail 3-Jan-11 6:29am    
I'm not sure why this answer is down-voted. The link is useful. I'll put my 5 to compensate. :)
Manfred Rudolf Bihy 3-Jan-11 6:34am    
@Nuri: Thanks! I appreciate it.
thatraja 3-Jan-11 13:07pm    
Not Counter voted, it's really a good answer. But I don't know why some enquirers downvoting the answers. Also I got downvotes for more than couple of questions same as like this recently(without comment is really annoying), It will make some answerers ignoring those enquirers. Have 5 Manfred.
Manfred Rudolf Bihy 3-Jan-11 13:11pm    
@Thatraja: Thank you for your kind words! Not to forget also for the vote :)
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            for (int c = 0; c < dataGridView1.ColumnCount; c++)
            {
                if (e.RowIndex < 0&& e.ColumnIndex == c)
                {
                    Font drawFont = new Font("Microsoft Sans Serif", 10);
                    SolidBrush drawBrush = new SolidBrush(Color.Black);

                    e.Graphics.DrawImage(Properties.Resources.title_bg_center, e.CellBounds);
                    e.Graphics.DrawString(dataGridView1.Columns[c].HeaderText, drawFont, drawBrush, e.CellBounds);

                    e.Handled = true;
                    drawBrush.Dispose();
                }
            }
        }
 
Share this answer
 
v2
Comments
Toniyo Jackson 3-Jan-11 6:23am    
Use pre tag for code.
Manfred Rudolf Bihy 3-Jan-11 6:37am    
@OP: What sense is there in posting some code you found on the site I gave you the link to. I hope you're not thinking somebody will give you points for that and I honest to god hope you didn't fall for the misconception you could vote for your own answer.
Please follow the forum guidelines!
Thanks for your attention!

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