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.

Custom Format

Thread ID:

Created:

Updated:

Platform:

Replies:

69532 Oct 31,2007 10:14 AM Nov 6,2007 02:52 PM Windows Forms 4
loading
Tags: GridControl
Qingde Shi
Asked On October 31, 2007 10:14 AM

Hi,

I have a problem formating CellValue in GridControl QueryCellInfo.

codes like this:
e.Style.CellValue =0.000001;
e.Style.Format = "0.00%; -0.00%; - ";

the - will be shown for the final result. because this is the normal framework behavior.

However, I want the - to be displayed only when CellValue equals zero (before any formating). so I format values first using a customized codes, and then assign the formatted value to e.Style.FormattedText. this works for the diaplay purpose, however, it overwrites the CellValue with the FormattedText.

My question is, how to display a customized formatted value while CellValue still stores original value?

Thanks,

Q

Qingde Shi
Replied On October 31, 2007 11:13 AM

Hi,

I think I find a workaround.
instead of passing a custom format string to e.Style.Format, let framework to the conditional format, I pass it with a format based on e.Style.CellValue condition.

Regards,

Q

Administrator [Syncfusion]
Replied On November 1, 2007 04:38 AM

Another solution might be to use the DrawCellDisplayText event. There, you can set e.DisplayText to be anything you want and see it when the grid draws the cell contents. Setting e.DisplayText in this event has absolutely no effect on the style.CellValue, style.FormattedText, or anything else to do with the style. It only specifies the text the grid will draw in the cell. It is a 'safe' place to do custom formatting on the display string.

Qingde Shi
Replied On November 6, 2007 10:24 AM

Clay,

Thanks. How do you retrieve the value set to e.DisplayText in code?

Another question. How to allow user to change
cell value format in a virtual grid? I would guess one has to cache the format user set and over write the one set in QueryCellInfo event. Do you have an example? this question could also extend to other style infos, like font size, bold, alignment etc.

Thanks,

Q


>Another solution might be to use the DrawCellDisplayText event. There, you can set e.DisplayText to be anything you want and see it when the grid draws the cell contents. Setting e.DisplayText in this event has absolutely no effect on the style.CellValue, style.FormattedText, or anything else to do with the style. It only specifies the text the grid will draw in the cell. It is a 'safe' place to do custom formatting on the display string.


haneefm [Syncfusion]
Replied On November 6, 2007 02:52 PM

Hi Q,

Regarding the Issue 1: How do you retrieve the value set to e.DisplayText in code?
>>>>>>>>>>>>>>>>>>>>>>
There is no direct way to retrieve the text that is set for any cell in the DrawCellDisplayText event. The GridStyleInfo object associated with the cell does not hold any information on this. However, we may get this by having a hashtable with row and the colIndex as the hashcode key.

Regarding the Issue 2: How to allow user to change cell value format in a virtual grid?
>>>>>>>>>>>>>>>>>>>>>>
In a virtual grid, you are responsible for saving any cell style property you want to use.

So, if you want to change style.Format / BackColor for a cell, then in your SaveCellInfo hanlder, you will have to save this property, and then in QueryCellInfo, you have to retrieve the property you saved and set it back into the requested style.

Best regards,
Haneef

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.

;