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

cell format & EnterKeyBehavior

Thread ID:

Created:

Updated:

Platform:

Replies:

27408 Apr 12,2005 01:54 PM UTC Apr 12,2005 04:53 PM UTC WinForms 2
loading
Tags: GridControl
Mick Speake
Asked On April 12, 2005 01:54 PM UTC

I am simulating a percent cell using a method described in another forum thread. This is fine all the time that hitting Enter causes movement to another cell. With EnterKeyBehavior=Right, hitting Enter in the right most column results in no movement(as expected)and so the % value is not displayed correctly until manually leaving the cell. How can I force the cell to display correctly in this situation? I have attached a small example which has a grid with 2 columns. Try inserting values & hitting Enter to see the problem. Regards, Mick TestPerc_8040.zip

Administrator [Syncfusion]
Replied On April 12, 2005 04:47 PM UTC

Selectively calling CurrentCell.EndEdit when you are in the last column worked around the problem in your sample. The code is below. Another option is to make the enter wrap to the next row. You can do this by setting a property. this.grid.Model.Options.WrapCellBehavior = GridWrapCellBehavior.WrapRow; But in this case, the sample problem will exist on the bottom most-right most cell. So, you would have to call EndEdit on the last cell in the grid to force the cell to lose focus in that case.
private bool inEvent = false;
private void grid_CurrentCellValidating(object sender, CancelEventArgs e)
{
	GridControlBase grid = sender as GridControlBase;
	GridCurrentCell cc = grid.CurrentCell;

	if(!inEvent && grid.Model[cc.RowIndex, cc.ColIndex].Format == "P2")
	{
		string s = cc.Renderer.ControlText;
		if(s.IndexOf("%") > -1)
			s = s.Replace("%","");
		double d;
		if(double.TryParse(s, System.Globalization.NumberStyles.Any, null, out d))
		{
			d/=100;
			cc.Renderer.Control.Text = d.ToString();
		}
		
		if(cc.ColIndex == grid.Model.ColCount)
		{
			inEvent = true;
			cc.EndEdit();
			inEvent = false;
		}
	}
}

Mick Speake
Replied On April 12, 2005 04:53 PM UTC

Many thanks, Clay. I tried cc.EndEdit() but failed as I didn''t know about "inEvent"! Regards, Mick

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

;