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.

Conditional formulas in a Grid?

Thread ID:

Created:

Updated:

Platform:

Replies:

3088 Feb 28,2003 07:48 PM Mar 3,2003 04:46 PM Windows Forms 3
loading
Tags: GridControl
Mac
Asked On February 28, 2003 07:48 PM

I have a formula in a Grid which works out a percentage increase. =(A1-B1)/A1 The problem is obviously, if A1 is zero, it brings up an error. Does Essential Grid support if statements in the formula like excel? (can't see anything in the documentation) If not, does anyone know a way which I can get around this? Regards Mac

Administrator [Syncfusion]
Replied On March 2, 2003 05:45 PM

Exactly, what do you want to see when you divid by zero? Right now your formula shows the word 'Infinity' representing a value obtained when you divide by zero. Do you want to change the word 'infinity' to something else? Or do you want to change the zero to some other value or something of that nature so you always see a number is that cell. To change the zero to some other value, you could write a custom function that handled, so a function names CheckIfZero. This function would eithe rreturn the value of the calculation if nonzero, and the other value if it is zero. To change the word, you could handle PreviewStyleInfo and swap it out there. If you will explain exactly what you want to see in the cel, I could try to post some code snippets.

Mac
Replied On March 3, 2003 03:29 PM

Hi Instead of having infinity being shown, in this example I would like to have a 0 being shown. This could 0 or something else, for example, in another grid, I would like to have 100 (as in 100%) being shown. Any help would be appreciated Mac

Administrator [Syncfusion]
Replied On March 3, 2003 04:46 PM

The simplest way to do this is to handle the PrepareViewStyleInfo event, and swap out the Inifinity there.
private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if(e.Style.FormattedText == "Infinity")
		e.Style.Text = "0";
}

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.

;