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.

Exiting edit mode after the user has clicked into a checkbox

Thread ID:

Created:

Updated:

Platform:

Replies:

11637 Mar 12,2004 03:38 AM Mar 12,2004 08:34 AM Windows Forms 4
loading
Tags: GridControl
Raul Rosenthal
Asked On March 12, 2004 03:38 AM

I have a bound grid with a column of type checkbox. When the user clicks on the checkbox, I alter some data in the CurrentCellChanged event handler to reflect the new state of the checkbox. At this point the current row is still in edit mode (as shown by the little pencil on the left edge). If the user aborts the edit (e.g. by pressing the ESC key) I have the checkbox reset to the previous state but the data I modified in the event handler stays - of course - changed. I would like to exit edit mode in the event handler, thus automatically confirming the change in the row. Alternatively, I''d like to trap the user operation that undoes the change to the row, so that I could restore the state of my data. So far I have been unable to make either solution work. Can you point me in the right direction? Please note that I''m using v1.6.x Thanks, Raul

Administrator [Syncfusion]
Replied On March 12, 2004 04:15 AM

In CurrentCellChanged, if you are on your checkbox, try this code: this.gridDataBoundGrid1.CurrentCell.EndEdit(); this.gridDataBoundGrid1.Binder.EndEdit();

Raul Rosenthal
Replied On March 12, 2004 05:46 AM

It works, more or less. Now pressing ESC after having clicked on the checkbox doesn''t revert the value of the checkbox to the previous state, but the little pencil doesn''t disappear, which may be a bit confusing to the user. Isn''t there a way to end the edit for the whole row? Thanks, Raul

Administrator [Syncfusion]
Replied On March 12, 2004 08:02 AM

grid.Binder.EndEdit is the proper method to call to get rid of the pencil. The problem is that with a checkbox cell, CurrentCellCahanged is fired before the Binder.BeginEdit call that puts the pencil in place. So, the pencil is appearing after your code is hit in CurrentCellChanged. So, it is being turned off before it is turned on. I looked around for a convenient event that woul doccur after the pencil is shown, an ddid not see one. So, as a not to elegent solution, you could add a timer, and enbled it is CurrentCellChanged, and then turn off the pencil in the tick event.
private void gridDataBoundGrid1_CurrentCellChanged(object sender, System.EventArgs e)
{
	//checkboxcell
	if(this.gridDataBoundGrid1.CurrentCell.ColIndex == 1) 
	{
		this.timer1.Interval = 30;
		this.timer1.Enabled = true;
	}
}

private void timer1_Tick(object sender, System.EventArgs e)
{
	this.timer1.Enabled = false;
	this.gridDataBoundGrid1.Binder.EndEdit();
}

Raul Rosenthal
Replied On March 12, 2004 08:34 AM

Boy, this IS ugly. ;-) Nevertheless, I think that I can live with that. Thank you. Regards, Raul

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.

;