none
How To Insert Image To DataGridView Column Header

    Question

  • Hi All,

    I wonder if it's possible to insert an image to a DataGridView Column Header.

    Tanks In Advance

    Boaz Shalev.

     

    Monday, January 02, 2006 8:29 AM

Answers

  • There isn't any Image property or such, but you can handle the CellPainting event and add the image to the column header. The RowIndex for the paint event will be -1 for column headers.

     

    -mark

    DataGridView Program Manager

    Microsoft

    This post is provided "as-is"-mark

     

     

    Tuesday, January 03, 2006 6:17 AM

All replies

  • There isn't any Image property or such, but you can handle the CellPainting event and add the image to the column header. The RowIndex for the paint event will be -1 for column headers.

     

    -mark

    DataGridView Program Manager

    Microsoft

    This post is provided "as-is"-mark

     

     

    Tuesday, January 03, 2006 6:17 AM
  • Hi Mark,

    Can you send me code sample ?

    Thanks

    Boaz Shalev.

    Tuesday, January 03, 2006 7:25 AM
  • Is their any solution without overriden the DataGridView? something like the pre and post paint events that each row sends?

     

    Tuesday, January 24, 2006 4:38 PM
  • Totally -- you can handle the CellPainting event and do this -- doesn't require overriding the DataGridView.

     

    -mark

    DataGridView Program Manager

    Microsoft

    This post is provided "as-is"

     

    Tuesday, January 24, 2006 6:38 PM
  • Hi.


    Can anyone tell how can i add an image to the rowHeader Column of a datagridview ?

    Help would be appreciated


    Regards 


    Monday, July 02, 2007 5:56 PM
  • Hi, There is a similar post for writing the image on RowHeader... pls refer..
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=51557&SiteID=1

     

    And, follwoing is the code from the post:

     
            protected override void  OnRowPostPaint(DataGridViewRowPostPaintEventArgs e)
            {
    // must call base event for other implementions
                base.OnRowPostPaint(e);           

    // Paint Circle on the rowHeader if needed
                if(_breakPoints.Contains(e.RowIndex))
                {
    // Gets the color to draw the circle with
                    Color rowColor = (Color)_breakPoints[e.RowIndex];
                    Brush circleColor = new SolidBrush(rowColor);
    // Draw the circle
                    e.Graphics.FillEllipse(circleColor, e.RowBounds.Location.X + 20,   
                                                  e.RowBounds.Location.Y + 4, 10, 10);
                }
                     
            }

    guess, this will help draw the column header also..

     

    Regards,

    Vivek

    Wednesday, July 18, 2007 10:27 AM
  • Hi
    Thanks a  lot  but ... i already knew that a even replied to that post ...
    Regards
    Wednesday, July 18, 2007 10:53 AM