The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I have some cell formatting code in the QueryCellStyleInfo event. In this event, I am doing something like
if (rowIndex=1) { e.Style.Text = "Weeks"; e.Style.TextColor = Color.Red; }
However, when the grid is initialize and this cell text and color is set, I do not want to always execute this block of code for obvious performance reason when the QueryCellStyleInfo fires, so I have place a flag to skip this code like below...
if (!FlagIsTextSet) { if (rowIndex=1) { e.Style.Text = "Weeks"; e.Style.TextColor = Color.Red; FlagIsTextSet = true; } }
However, when I resize my the grid/form or make some changes elsewhre, I lose my text formatting.
ADAdministrator Syncfusion Team January 23, 2007 06:18 PM UTC
Hi James,
Thanks for being patience.
The reason for the style is being reset is that the grid will query for the cell style properties when it draws or re-draw it on the screen. In this case, the grid tries to re-draw the cells, when the form re-sizes.
The setting of style properties using the QueryCellStyleInfo event doesn’t affect performance if proper conditional statements are given. For example, to set text color for the records the drawing display element can be checked for record row and accordingly set the style property.
Generally, in GridGroupingControl the style properties for the cell are set by checking for TableCellType and accordingly changed.
In the following code snippet, the style has been changed for a summary cell. This statement only executed only when the summary cell is displayed on the display screen. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> // QueryCellStyleInfo event. if (e.TableCellIdentity.TableCellType == GridTableCellType.SummaryFieldCell) { e.Style.BackColor = Color.AliceBlue; } >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
In your code snippet, the flag in the event is not required because the statement will be executed only when the row index with 1 is displayed in the screen and this doesn’t affect your performance any way.
Kindly let us know if you need any further assistance. Have a nice day.