Conditional Formatting on a booleanColumn

9 posts, 0 answers
  1. Chris Castle
    Chris Castle avatar
    33 posts
    Member since:
    Mar 2006

    Posted 13 Nov 2007 Link to this post

    Is it possible to use Conditional Formatting on a BooleanColumn.  I can't get it to work so I must be missing something.
  2. Jack
    Jack avatar
    2335 posts

    Posted 14 Nov 2007 Link to this post

    Hello Chris Castle,

    Thank you for writing.

    Yes, it is possible to use conditional formatting on a boolean column. The following sample demonstrates how to do this:

    DataTable table = new DataTable(); 
    for (int i = 0; i < 5; i++) 
        table.Rows.Add(i, "Row " + i, true); 
    this.radGridView1.MasterGridViewTemplate.AutoGenerateColumns = false
    this.radGridView1.Columns.Add(new GridViewTextBoxColumn("ID")); 
    this.radGridView1.Columns.Add(new GridViewTextBoxColumn("Name")); 
    GridViewBooleanColumn column = new GridViewBooleanColumn("Boolean");             
    this.radGridView1.DataSource = table; 
    this.radGridView1.RightToLeft = RightToLeft.Yes; 
    ConditionalFormattingObject obj = new ConditionalFormattingObject("Condition", ConditionTypes.Greater, "1"""false); 
    obj.CellBackColor = Color.Red; 

    In case you have additional questions, don't hesitate to contact us.

    All the best,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. DevCraft banner
  4. Eric
    Eric avatar
    28 posts
    Member since:
    Nov 2007

    Posted 27 Nov 2007 Link to this post

    This does not seem to work for me.  I even tried to use the RadGridView Conditional Formatting demo and I can't seem to get the formatting to work for the "Bool" column.  Can you tell me what the condition settings should be for the demo to get it to work?
  5. Jack
    Jack avatar
    2335 posts

    Posted 28 Nov 2007 Link to this post

    Hello Eric,

    We tested the solution sent to you and found an issue related to checkbox columns. Unfortunately the conditional formatting does not evaluate these kinds of columns correctly. We will fix this in the upcoming release in December.

    As a workaround I can offer you to use the CellFormatting event. Refer to the sample code below:

    void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e) 
        if (e.CellElement is GridCheckBoxCellElement) 
            if ((bool)e.CellElement.Value) 
                e.CellElement.DrawFill = true
                e.CellElement.BackColor = Color.Red; 
                e.CellElement.DrawFill = false

    Please, tell us if this solution helps.

    Best wishes,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Tim
    Tim avatar
    54 posts
    Member since:
    Apr 2007

    Posted 25 Feb 2008 Link to this post

    has this issue been resolved?  I'm using the Q3 release and I'm having the same issue.

    Nevermind.... I figured it out.

    I need the row color changed if the marker was set to false which means I needed to use:


    obj = new ConditionalFormattingObject("Complete", ConditionTypes.Less, "1", "", true);

    Although a little note for Telerik, this seems a little confusing for use with a boolean columns.  Is there a way in the future when coding in manually like this, to have the ConditionalFormattingObject overloaded to accept a bool as a value rather than 2 strings?  Just a thought.


    Correction again.... the above code does indeed change the color of the rows.... but but all my rows were false until, so I didn't see this until now.  So now I have a mix of T & F in the same column, and with the above code, all the rows are colored when only the false rows are to be colored... I even tried adding another line to evaluated for true, but that didn't help... its like all or nothing.....

  7. Jack
    Jack avatar
    2335 posts

    Posted 26 Feb 2008 Link to this post

    Hello Tim,

    Thank you for writing us.

    Unfortunately, this issue still exists in the current latest release of RadGridView. We will address it in the Q1 2008 release. We will revise our API and will add such an overload to the ConditionalFormattingObject.

    Thank you for your suggestions.

    Do not hesitate to contact us, if you have other questions.

    All the best,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Guy
    Guy avatar
    2 posts
    Member since:
    Mar 2008

    Posted 20 Oct 2008 Link to this post

    Hi ,
    Did you fix this for the 2008 Q1 ?

  9. Jack
    Jack avatar
    2335 posts

    Posted 24 Oct 2008 Link to this post

    Hello Guy,

    Thank you for this question.

    Actually, we decided to leave the ConditionalFormattingObject constructors as they are. There is no overload that takes a boolean property as an argument. Nevertheless, the conditional formatting works fine with boolean columns in our latest release. You could also process the CellFormatting event as an alternative solution to this issue.

    I strongly recommend updating to the latest release of RadControls. If you need any further assistance, I will be glad to help you.

    Kind regards,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  10. Skurken
    Skurken avatar
    1 posts
    Member since:
    Aug 2006

    Posted 29 Jun 2009 Link to this post

    Nvm :)
Back to Top
DevCraft banner