Hi all,
1>I have a datagrid control containing date column. I want to highlight the row for today's date or nearest to today when page is loaded.
if anybody can help me, i will really appriciate it.
Thanks,
NIKI
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Nilesh JagdalePosted Jun 28, 2006, 2:13 AM
Try This .Idea is to override paint..This is working even i worked on it.copy and change according to your requirement...
class DataGridColoredTextBoxColumn : DataGridTextBoxColumnpublic
{
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 // depending upon some criteria on the cell value try{
DataTable dtPaint;
DataRow drPaint;
dtPaint = ((DataView)
this.DataGridTableStyle.DataGrid.DataSource).Table;drPaint = dtPaint.Rows[rowNum];
//If Amount Mismatch then highlight if (drPaint["Amount"].ToString() != drPaint["Last Amount"].ToString()){
backBrush =
new LinearGradientBrush(bounds,Color.IndianRed,
Color.IndianRed,
LinearGradientMode.BackwardDiagonal);
foreBrush =
new SolidBrush(Color.White);}
}
catch(Exception ex){ ex.ToString(); }
finally{
// make sure the base class gets called to do the drawing with // the possibly changed brushes base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);}
}
}
Regards,
Nilesh
DhruvilPosted Jun 27, 2006, 9:13 AM
Nilesh JagdalePosted Jun 27, 2006, 2:12 AM
Just go thru following link. I hope this will help you..
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q745q
Regards,
Nilesh.