Get invalid expression when using GridAwareTextBox along multiline property

I have the following problem in my application but I was also able to reproduce it in your sample that you shipped with Syncfusion ($\Program Files\Syncfusion\Essential Suite\3.0.1.6\Windows\Grid.Windows\Samples\Quick Start\FormulaGrid). Simply change the property of multiline in textbox1 to true and run it. Enter the formula such as "=1+1" in textbox1 (which is GridAwareTextBox) and enter you end up with "invalid expression in the proper cell in gridControl1. In my application I need to have multiline since some of our formula are long and we like our clients to be able to see the whole formula not just part of it. I don''t see this in standalone EXCEL and also in your samples that use IWorkbook. It seems this problem also related to AcceptsReturn property as well. Your help is appreciated.

4 Replies

AD Administrator Syncfusion Team August 5, 2005 04:31 PM UTC

The error in our sample that you described can be avoided by handling the CurrentCellValidating event.
string enter = Environment.NewLine;
private void gridControl1_CurrentCellValidating(object sender, CancelEventArgs e)
{
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	GridStyleInfo style = this.gridControl1[cc.RowIndex, cc.ColIndex];
	if(style.CellType == "FormulaCell" && cc.Renderer.ControlText.IndexOf(enter) > -1)
	{
			cc.Renderer.Control.Text = cc.Renderer.ControlText.Replace(enter, "");
	}
}
But I am not sure this will give you all the behavior you want. You may also have to set othe rproperties like this.gridControl1.TableStyle.AllowEnter = true; if you want to be able to hit enter in a cell without moving to the next cell. There is also a grid.EnterKeyBehavior property that may need to be set.


NJ Najmeh Joze-khajavi August 5, 2005 07:52 PM UTC

Thanks for help. But I need to know one more thing to adjust your code in my application. I have TabBarSplitter control and array of gridControls very similar to Syncfusion sample "NamedRangesForFormula. I added the following event: private void SettingsAndWorkSheets_CurrentCellValidating(object sender, CancelEventArgs e) { GridCurrentCell cc = this._WorkSheetGrid[0].CurrentCell; GridStyleInfo style = this._WorkSheetGrid[0][cc.RowIndex, cc.ColIndex]; if(style.CellType == "FormulaCell" && cc.Renderer.ControlText.IndexOf(enter) > -1) { cc.Renderer.Control.Text = cc.Renderer.ControlText.Replace(enter, ""); } } I need to know the active worksheetGrid in run time. How can I get this information? I mean when in run time we move from one WorksheetGrid to another WorksheetGrid how do I know which worksheet I am currently. The above code only works for the first WorkSheetGrid.


AD Administrator Syncfusion Team August 5, 2005 10:46 PM UTC

You can cast the sender to a GridControl and use that to get the proper current cell. GridControl grid = sender as GridControl; if(grid != null) { GridCurrentCell cc = grid.CurrentCell; ///........ }

NJ Najmeh Joze-khajavi August 8, 2005 01:59 PM UTC

Your solution works. But I also came up using ActivePageIndex to find out which page is selected. int activeIndex = this._SettingsTabBarSplitterControl.ActivePageIndex; GridCurrentCell cc = this._WorkSheetGrid[activeIndex].CurrentCell; .... Thanks >You can cast the sender to a GridControl and use that to get the proper current cell. > > >GridControl grid = sender as GridControl; >if(grid != null) >{ > GridCurrentCell cc = grid.CurrentCell; > ///........ >} >
Loader.
Up arrow icon