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

Get invalid expression when using GridAwareTextBox along multiline property

Thread ID:

Created:

Updated:

Platform:

Replies:

32692 Aug 5,2005 02:52 PM UTC Aug 8,2005 01:59 PM UTC WinForms 4
loading
Tags: GridControl
Najmeh Joze-khajavi
Asked On August 5, 2005 02:52 PM UTC

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.

Administrator [Syncfusion]
Replied On 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.

Najmeh Joze-khajavi
Replied On 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.

Administrator [Syncfusion]
Replied On 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; ///........ }

Najmeh Joze-khajavi
Replied On 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; > ///........ >} >

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

;