MarcDV
2020-12-24T13:05:25Z
Bonjour à tous,

J'ai un programme (winforms) avec 4 iGrid.
3 de ceux-ci ont l’événement celldynamicformatting.
L’événement se déclenche et fait bien sont office. jusque là c'est ok ;-)

Le problème c'est que lorsque je suis en focus sur l'Igrid qui a cet événement, le CPU augmente de 25 %. Et en debug il est en effet en permanence en train de le faire tourner.

Quel est le problème ?
Si c'est un bug connu, y'a-t-il moyen de pratiquer autrement ?
Je n'ai besoin que d'une passe sur la grille pour mettre certaines cellules en couleur suivant le contenu. Je n'ai pas besoin de rafraîchir en permanence.

Merci d'avance pour votre aide ;-)
Igor/10Tec
2020-12-24T16:46:03Z
The CellDynamicFormatting event is raised as a part of the drawing cycle. In normal conditions, it is raised only one time for every corresponding cell. If it is raised constantly and the CPU usage jumps up to 25% (most likely, it is a quad-core CPU), this may mean that you may have additional actions related to focus change that causes additional redrawing operations for the grid.

Can you reproduce the same problem in a brand new project with iGrid that has only the CellDynamicFormatting event handler? If yes, send this sample to us for the further consideration.
MarcDV
2021-01-07T15:59:11Z
Sorry for the delay ;-)

Here is the program :   EssaiGrid.zip (410kb) downloaded 2 time(s).

When I'm on the first tab (where the Grid is), I'm at 25% CPU time.
If I am on the second one, I am at 0%.

I even force the focus on the button, but it doesn't change anything.

Thanks for your help
Igor/10Tec
2021-01-08T08:36:43Z
Look at your CellDynamicFormatting event handler:

private void iGrid1_CellDynamicFormatting_1(object sender, TenTec.Windows.iGridLib.iGCellDynamicFormattingEventArgs e)
{
    iGrid1.Cells[e.RowIndex, 0].BackColor = Color.Red;
}

We explain why you must not change cell formatting directly with cell properties in the help topic dedicated to the CellDynamicFormatting event:

Quote:

Note that in this event you should change the formatting of the cell only through the arguments of this event (such as e.BackColor) but not directly accessing the cell in iGrid. In the latter case this causes an infinite loop as iGrid needs to update the cell after such a change, and the CellDynamicFormatting event is raised at that again. As a result, your application may hang or become unresponsive.



The right way to highlight the cells in the first column using dynamic formatting is the following:

private void iGrid1_CellDynamicFormatting_1(object sender, TenTec.Windows.iGridLib.iGCellDynamicFormattingEventArgs e)
{
    if (e.ColIndex == 0)
        e.BackColor = Color.Red;
}
MarcDV
2021-01-08T13:04:28Z
Indeed, it is much better this way ;-)

Many thanks for your help !