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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Formula engine values

Thread ID:

Created:

Updated:

Platform:

Replies:

68934 Oct 5,2007 03:44 PM UTC Oct 5,2007 11:39 PM UTC WinForms 1
loading
Tags: GridControl
Stephen Main
Asked On October 5, 2007 03:44 PM UTC

Hi,

Is it possible to override the values that the formulae engine receives? (It doesn't look like you can override any of the members in GridFormulaEngine).

I have a custom property that holds a 'percentage object' and a custom cell model with an overidden OnPrepareViewStyleInfo method that facilitates percentage formatting so that e.g. 10 % is formatted as 10.00 (without the % sign) but the value of the 'percentage object' is actualy 0.10.


All operations in our app refer to the custom property's 'percentage object' value property.
This works fine except that formulae return cell value. If we could override the way the formula engine gets its values so that it interrogates the custom preperties first, then this would not be an issue.

Alternatively, is there an easy way of formatting a percentage without the "%" character?
I do not want to change the system's CultureInfo object as I want to choose which cells show "%" and which show withount "%" character.

haneefm [Syncfusion]
Replied On October 5, 2007 11:39 PM UTC

Hi steve_randomno,

There are special formatting events that you could use to control the formatting. The events are QueryCellFormattedText and DrawCellDisplayText event. Below are some snippets that show how to customize the formating of the cells in a grid.

private void GridDrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
if(e.Style.CellType = "FormulaCell" && e.DisplayText != null && e.DisplayText != string.Empty )
{
double dvalue = Double.Parse(e.Style.CellValue.ToString());
e.DisplayText = String.Format("{0:#,##0,,.0MB}",dvalue) ; //Your Format
}
}

private void GridQueryCellFormattedText(object sender, GridCellTextEventArgs e)
{
if (e.Style.CellType == "FormulaCell" )
{
string s = e.Style.Text;
double dvalue = Double.Parse(e.Style.CellValue.ToString());
e.Text = String.Format("{0:#,##0,,.0MB}",dvalue) ; //Your Format
e.Handled = true;
}
}

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.

Warning Icon 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.Close Icon

;