We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Cell formatting lost when i don''t alway execute code in QueryCellStyleInfo

Thread ID:

Created:

Updated:

Platform:

Replies:

55029 Jan 22,2007 07:03 PM Jan 23,2007 01:18 PM Windows Forms 1
loading
Tags: Grouping
James Blibo
Asked On January 22, 2007 07:03 PM

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.

What gives?

Administrator [Syncfusion]
Replied On January 23, 2007 01:18 PM

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.

Best regards,
Madhan

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;