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

DirectSaveCellInfo in DataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

27552 Apr 14,2005 11:43 AM UTC Apr 15,2005 09:53 AM UTC WinForms 7
loading
Tags: GridControl
Vinay
Asked On April 14, 2005 11:43 AM UTC

Hi Clay, We have a databoundgrid for which we have set the Binder.DirectSaveCellInfo = True. But when we press delete on a cell before it goes to edit mode or a clipboard cut operation is performed any changes made to the cell is not saved immediately but will be saved after focus moves to another row. For some reason the directcellSaveCellinfo is set to false when a delete operation is performed. Regards Vinay

Administrator [Syncfusion]
Replied On April 14, 2005 12:22 PM UTC

If I select several cells in 3.0.1.0, and then press delete with DirectSaveCellInfo = true, then the chnages seem to go directly to the datatable. But if I have a single cell selected (and not editing), then presseing delete clears the cell, and puts it into edit mode without settingthe changed value in the datatable. The reason is thatthe cell is still editing at this point. If you do not want this behavior, then one way to handl ethis is to derive the grid and override OnCurrentCellControlKeyMessage and end the editing on teh current cell after calling the baseclass. Here is a derived grid that worked for me.
public class MyGridDataBoundGrid : GridDataBoundGrid
{
protected override void OnCurrentCellControlKeyMessage(GridCurrentCellControlKeyMessageEventArgs e)
{
	Keys keyCode = (Keys) ((int)e.Msg.WParam) & Keys.KeyCode;
	base.OnCurrentCellControlKeyMessage (e);
	if(keyCode == Keys.Delete && this.CurrentCell.Renderer.ControlText.Length == 0)
		this.CurrentCell.EndEdit();
}
}

Vinay
Replied On April 14, 2005 12:51 PM UTC

Hi Clay Thanks for the help. I have another requirement where in when a cell is being edited and the user hits the return key the current cell should stop editing and the focus should remain in the same cell instead of moving to the next cell. TO implement this i have inherited the Textboxcell renederer class and overrided the keydown event. The code in keydown event is given below. if (!e.Handled && e.KeyCode == Keys.Return && CurrentCell.IsEditing) { CurrentCell.ConfirmChanges(); CurrentCell.EndEdit(); e.Handled = true; } base.OnKeyDown(e) With the above code i am able to stop the current cell being moved but if the user enters any other key the cell does not go back to edit mode. And another problem is that if the user hits the left arrow the cell does not move to the previous cell (it moves after hitting the left arrow 2-3 times) but with the right arrow the currentcell moves the next cell with single hit. Regards Vinay

Administrator [Syncfusion]
Replied On April 14, 2005 12:59 PM UTC

Have you tried not calling the base class when you handle the key? If you can create a little project with a gridcontrol on a form and add your custom cell code and upload it, then we can try to find a solution to your problem here.

Vinay
Replied On April 14, 2005 01:38 PM UTC

Hi, I have tried implementing it without calling the Base.OnKeydown if it has already been handled but it still doesnt work. I have attached a sample where you replicate the problem. regards Vinay WindowsApplication1_3653.zip

Administrator [Syncfusion]
Replied On April 14, 2005 03:10 PM UTC

Try this code.
if (!e.Handled && e.KeyCode == Keys.Return && CurrentCell.IsEditing)
{
	CurrentCell.ConfirmChanges();
	CurrentCell.CancelEdit();
	e.Handled = true;
	return;
}

Vinay
Replied On April 15, 2005 06:37 AM UTC

Hi Clay, Thanks for the help. Regarding the directsavecellinfo we are still facing problems. We have a databoundgrid whose Binder.DirectSaveCellInfo is set to true. we want the data to reflect onto the column as soon as the user finishes editing a cell and not when the user moves onto another row. When the user selects more than one cell and presses delete the data is saved immediately but after that any edit will not reflect immediately onto the record but will reflect only after the user moves on onto any other row. The binder.directsavecellinfo sets itself back to False when the user presses delete selecting a range of cell. Regards Vinay

Administrator [Syncfusion]
Replied On April 15, 2005 09:53 AM UTC

If you want the change to be pushed to the datasource whne you leave the cell (as opposed to when you leave the row), try handling CurrentCellAcceptedChanges and ending the binder edit there.
private void gridDataBoundGrid1_CurrentCellAcceptedChanges(object sender, CancelEventArgs e)
{
	this.gridDataBoundGrid1.Binder.EndEdit();
}

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

;