Change row color with date value

6 posts, 1 answers
  1. Tiago
    Tiago avatar
    25 posts
    Member since:
    Aug 2009

    Posted 15 Oct 2009 Link to this post

    Dear friends,

    I have a read only RadGridView with several columns. One of those columns is a date, and i want to change the backcolor of the rows that have the date smaller than today's data.

    Can you help me?

    Thanks in advance.
  2. Tom Chien
    Tom Chien avatar
    125 posts
    Member since:
    Jun 2009

    Posted 15 Oct 2009 Link to this post

    Well, you'd think you could do it by adding a ConditionalFormattingObject using RadGridView.Columns.Item(your date column's name / index).ConditionalFormattingObjectList.Add method.  I haven't been able to get it to work with comparison values other than blank.  So how do you do it, Telerik?  Inquiring minds want to know.

    Telerik 2009Q2 (2009.2.9.729), VS 2005 (v8.0.50727.762 SP.050727-7600), XP SP3 on Core2Duo 2.99GHZ with 3GB.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Tom Chien
    Tom Chien avatar
    125 posts
    Member since:
    Jun 2009

    Posted 16 Oct 2009 Link to this post

    You can always manually implement conditional formatting using the CellFormatting Event.  However, that means the user can't add, edit or delete the formatting (unless you also implement your own Conditional Formats Editor) it and it can't be saved / loaded by SaveLayout / LoadLayout (unless you manually add / remove-interpret it before / after the calls to SaveLayout / LoadLayout ).  Getting the ConditionalFormattingObject to support comparing non-blank Date values would still be the ideal solution.  What say ye, Telerik
  5. Tiago
    Tiago avatar
    25 posts
    Member since:
    Aug 2009

    Posted 16 Oct 2009 Link to this post

    Hey Tom,

    Thanks for your help at this time.

    I've been able to do some DataBase side validations, and, when my column with the name "state" comes with the int value 5, i must set that row background to red. I'm kinda confused right now, could you give me an example on how could i do that?

    Thanks again.
  6. Answer
    Tom Chien
    Tom Chien avatar
    125 posts
    Member since:
    Jun 2009

    Posted 16 Oct 2009 Link to this post

    I thought you were trying to change row colors based on a date value of a column of those rows.  The only problem I was having was with Conditional Formatting based on non-blank date values. 

    You should be able to do what you just described by doing something like the following:

    with oMyRadGrid.MasterGridViewTemplate 
        Dim oHiLtSt5RowsFmt As New ConditionalFormattingObject("HiLtSt5RowsFmt", ConditionTypes.NotEqual, "5"""True
        oHiLtSt5RowsFmt.CellBackColor = Red 
      .Columns.Item("MyStateColumnHeaderName").ConditionalFormattingObjectList.Add(oHiLtSt5RowsFmt) 
    end with ' -- oMyRadGrid.MasterGridViewTemplate 
     

  7. Tiago
    Tiago avatar
    25 posts
    Member since:
    Aug 2009

    Posted 19 Oct 2009 Link to this post

    Dear Tom,

    Thanks once again.

    Please take a look at this ... check the last post! :)

Back to Top
UI for WinForms is Visual Studio 2017 Ready