Conditional Formatting

6 posts, 0 answers
  1. Kristof
    Kristof avatar
    32 posts
    Member since:
    Oct 2006

    Posted 24 May 2007 Link to this post

    Hi,

    I have a gridview with data, similar to your example gridview on conditional formatting. I copy / pasted the example code for conditional formatting but I don't get it to work properly.
    The problem is that there is no initial formatting. The gridview has it's standard look. Only after clicking on a cell that contains the formatting-conditional text, the row gets the correct color. Your example seems to work fine, but I see no differences between that code and mine.

     

    radGridView1.CellFormatting += new CellFormattingEventHandler(radGridView1_CellFormatting);  
    radGridView1.DataSource = meterObjectValueList;  
    radGridView1.Refresh();  
     
    GridViewColumn col = radGridView1.MasterGridViewTemplate.Columns.FindByDataField("State");  
    ConditionalFormattingObject c1 = new ConditionalFormattingObject("ValueRead", ConditionTypes.Equal, "read"""true);  
    c1.RowBackColor = Color.Green;  
    c1.RowForeColor = Color.Black;  
    col.ConditionalFormattingObjectList.Add(c1);  
    ConditionalFormattingObject c2 = new ConditionalFormattingObject("ValueInit", ConditionTypes.Equal, "init"""true);  
    c2.RowBackColor = Color.Blue;  
    col.ConditionalFormattingObjectList.Add(c2);  
    radGridView1.MasterGridViewInfo.UpdateView();  
    radGridView1.Refresh(); 

     
    Am I missing something?

    Ben.

  2. Kiril
    Admin
    Kiril avatar
    158 posts

    Posted 24 May 2007 Link to this post

    Hi Kristof,

    Thank you for bringing this issue to our attention.

    I copy-pasted your code into a sample project and ran it, but I could not reproduce the problem. I think the problem might be coming from the handler of the CellFormatting event, but I do not have this piece of the puzzle.

    Could you send me a sample project which reproduces the problem you're experiencing, or alternatively, the code in the CellFormatting handler? You can do so in a support ticket.

    Thanks in advance.
     

    Kind regards,
    Kiril
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Kristof
    Kristof avatar
    32 posts
    Member since:
    Oct 2006

    Posted 24 May 2007 Link to this post

    Thanks for thinking with me!

    I found the cause of the problem: the column I use for formatting is displaying enum values. If I use a different column with real string values bound to it, then it actually works.

    So, to reproduce the problem, simply add an enum to the datasource and bind it to a column and then try conditional formatting.

    Probably the check "IsEqual" doesn't return a match when checking against enums. This could be solved by checking against the enum.ToString();

    Cheers,

    Ben

    p.s. happy holidays
  5. Kiril
    Admin
    Kiril avatar
    158 posts

    Posted 28 May 2007 Link to this post

    Thanks a lot for reporting this issue, Kristof. It will be fixed in the upcoming Service Pack 2. I have updated your Telerik points for the report.

    If you have any other questions, please feel free to contact us.


    Sincerely yours,
    Kiril
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Leadeng Leadeng
    Leadeng Leadeng avatar
    21 posts
    Member since:
    Mar 2008

    Posted 26 Jun 2008 Link to this post

    Hi, Looks like this problem still exist in 2008.1.619 version of RadControls for winforms.

    I'm applying conditional formatiiing on enum column and it does not work.

    Srini
  7. Kiril
    Admin
    Kiril avatar
    158 posts

    Posted 27 Jun 2008 Link to this post

    Hi Leadeng Leadeng,

    Thank you for writing.

    I could not reproduce the issue you are describing. I created a DataTable with two columns, one of them of type int, and the other one of type MyFlag, defined as follows:

        public enum MyFlag  
        {  
            On = 0,  
            Off = 1,  
            Indeterminate = 2  
        } 

    This table was then bound to the grid.

    Immediately after the databinding, two conditional formatting objects were created and added to the grid as shown in the code below:

                ConditionalFormattingObject c1 = new ConditionalFormattingObject();  
                c1.CellBackColor = Color.Red;  
                c1.ApplyToRow = true;  
                c1.ConditionType = ConditionTypes.Equal;  
                c1.TValue1 = "1";  
                c1.Name = "red";  
     
                ConditionalFormattingObject c2 = new ConditionalFormattingObject();  
                c2.CellBackColor = Color.Blue;  
                c2.ApplyToRow = true;  
                c2.ConditionType = ConditionTypes.Equal;  
                c2.TValue1 = "2";  
                c2.Name = "blue";  
     
                radGridView1.MasterGridViewTemplate.Columns[1].ConditionalFormattingObjectList.Add(c1);  
                radGridView1.MasterGridViewTemplate.Columns[1].ConditionalFormattingObjectList.Add(c2); 

    Please replicate the scenario that I tested, and let me know if you experience any issues. Furthermore, do not hesitate to contact us with any other questions you have.

    All the best,
    Kiril
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top
UI for WinForms is Visual Studio 2017 Ready