Hi Techies,
I have written code in windows C# based application to color/highlight an individual cell of datagrid depending upon its value eg. For each row if value in Column1 and column2 is not equal then highlight that cell with red color.
I have overridden Paint in a derived column style and set the back color there.
Its working fine but whenever I click on column header for sorting color do not change accordingly. Cell color of datagrid doesn’t change along with sorting; I hope you are getting what is my problem. Urgent help needed.
Here is sample code :
public class DataGridColoredTextBoxColumn : DataGridTextBoxColumn
{
protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight)
// the idea is to conditionally set the foreBrush and/or backbrush
DataTable dtPaint;
DataRow drPaint;
dtPaint = ((DataView)
drPaint = dtPaint.Rows[rowNum];
backBrush =
Color.IndianRed,
LinearGradientMode.BackwardDiagonal);
foreBrush =
}
{ ex.ToString(); }
Regards,