This is a migrated thread and some comments may be shown as answers.

CellFormatting event is fired high frequence

5 Answers 228 Views
GridView
This is a migrated thread and some comments may be shown as answers.
kevin
Top achievements
Rank 1
kevin asked on 07 Jan 2011, 04:45 AM
Hi,
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?


Regrads!

5 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 07 Jan 2011, 08:28 AM
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;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.BackColorProperty);
        e.CellElement.ResetValue(LightVisualElement.DrawFillProperty);
    }
}

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

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Richard Slade
Top achievements
Rank 2
answered on 07 Jan 2011, 10:05 AM
Hi Kevin,

In addition to the exmaple provided by Emanuel, please take a look at the documentation on formatting cells
Hope that helps
Richard
0
Jack
Telerik team
answered on 10 Jan 2011, 10:26 AM
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.

Greetings,
Jack
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.
0
Miguel Angel
Top achievements
Rank 1
answered on 03 Oct 2012, 10:21 PM
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 ...
0
Nikolay
Telerik team
answered on 05 Oct 2012, 02:46 PM
Hi Miguel,

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

All the best,
Nikolay
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
kevin
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Richard Slade
Top achievements
Rank 2
Jack
Telerik team
Miguel Angel
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or