C# – How to add different icons/images to datagridview row header in c#

cdatagridviewwinforms

I want to add different image to c# windows form datagridview row header dynamically. it should be do like check any cell value and if it>10 display some image,else display other image.How to do this one?please help me………..

Best Answer

Add a OnRowDataBound event handler to the GridView

In the event handler - check for the header and process each column accordingly

protected virtual void OnRowDataBound(GridViewRowEventArgs e) {
   if (e.Row.RowType == DataControlRowType.Header) {
       // process your header here..
    }
}

For more info go here: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridviewroweventargs.row.aspx