CellFormatting event is fired high frequence

6 posts, 0 answers
  1. kevin
    kevin avatar
    9 posts
    Member since:
    Dec 2010

    Posted 06 Jan 2011 Link to this post

    When the program execute the following codes:
     this.radGridView1.Rows[1].Cells[1].Style.DrawFill = true;
     his.radGridView1.Rows[1].Cells[1].Style.NumberOfColors = 1;
     this.radGridView1.Rows[1].Cells[1].Style.CustomizeFill = true;
     this.radGridView1.Rows[1].Cells[1].Style.BackColor = Color.Brown;

    all the cells of the second row will trig the cellFormatting event. The performace is low.

    Can we avoid it ,and only make the above cell to trig the cellformatting event?

  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 07 Jan 2011 Link to this post

    Hello Kevin,

    The formatting you require should be done using the CellFormatting event, not by setting the style of the cell, an example on how to do this would be the following:
    void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
        if (e.CellElement.ColumnIndex == 1)
            e.CellElement.BackColor = Color.Brown;
            e.CellElement.DrawFill = true;

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  3. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 07 Jan 2011 Link to this post

    Hi Kevin,

    In addition to the exmaple provided by Emanuel, please take a look at the documentation on formatting cells
    Hope that helps
  4. Jack
    Jack avatar
    2333 posts

    Posted 10 Jan 2011 Link to this post

    Hi kevin,

    As Richard said, you can increase the speed by handling the CellFormatting event instead of using the Style property. In addition you can use the BeginUpdate/EndUpdate methods of GridViewTemplate. However, I will be able to be more precise in my answer if I know more details regarding your scenario. Please open a support ticket send me your application and I will try to find the best option.

    Should you have any other questions, do not hesitate to ask.

    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  5. Miguel Angel
    Miguel Angel avatar
    3 posts
    Member since:
    Oct 2012

    Posted 03 Oct 2012 Link to this post

    Sorry for the English:

    CellFormatting I am using to format the cells and to place an image indicating that cell of the grid has a note.

    The grid is used to display information from various shops and I have a pageview to view information in a store at a time. The problem arises when I change and who remain store the images of the notes above the store.

    Sometimes I also put the image in a cell that carries no notice and no reason it happens.

    Could you help me. We have a license but not as Tellerik up these questions with the license, take this comment.

    Greetings ...
  6. Nikolay
    Nikolay avatar
    1805 posts

    Posted 05 Oct 2012 Link to this post

    Hi Miguel,

    You can find my answers in the supoprt ticket that you have opened. Let's continue our conversation there.

    All the best,
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Back to Top