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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

cannot understand formula

Thread ID:

Created:

Updated:

Platform:

Replies:

16322 Jul 12,2004 07:14 PM UTC Jul 13,2004 05:26 AM UTC WinForms 1
loading
Tags: GridControl
Jenny
Asked On July 12, 2004 07:14 PM UTC

Hi, Could you please help with the formula problem?: I cannot understand the meaning of this line of code in grid sample: e.Style.Text = string.Format("=({0}{1} + {2}{1})", GridRangeInfo.GetAlphaLabel(1), GridRangeInfo.GetNumericLabel(e.RowIndex),GridRangeInfo.GetAlphaLabel(2)); I need to get sum of cells from G to M. Also I do not want to display to user the string “=G1+H1+…” when he click on cell. Actually I need to have that formula cell ReadOnly Thanks in advance

Administrator [Syncfusion]
Replied On July 13, 2004 05:26 AM UTC

The method, string.Format, returns a string. The first argument for string.Format is a string that defines what the returned string should be. In this first argument, {x} where x in an integer, defines tokens that represent the values from the other items in the string.Format arguement list. So, {0} represents the value of the second argument in the string.Format argument list, {1} is the 3rd argument, and so on. GridRangeInfo.GetAlphaLabel is a function that accepts an integer and returns the corresponding letter of the alphabet that normally serves as the column header text for the particular column. So, GridRangeInfo.GetAlphaLabel(1) is "A", GridRangeInfo.GetAlphaLabel(2) is "B", and so on. The other method does the same except it returns a number that normally serves an teh row header text, "1", "2" etc. One way to prevent the formula from displaying is to handle the CurrentCellStartEditing event and cancel it if it is a formula cell you don''t want to edit.
private void gridControl1_CurrentCellStartEditing(object sender, CancelEventArgs e)
{
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	if(this.gridControl1[cc.RowIndex, cc.ColIndex].CellType == "FormulaCell")
		e.Cancel = true;
} 

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

;