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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Nilesh Jagdale14 reputationPosted Jun 26, 2006, 10:12 PM EDT
Just go thru following link. I hope this will help you..
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q745q
Regards,
Nilesh.
Dhruvil13 reputationPosted Jun 27, 2006, 5:13 AM EDT
Nilesh Jagdale14 reputationPosted Jun 27, 2006, 10:13 PM EDT
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