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. Image for the cookie policy date

DirectSaveCellInfo in DataBoundGrid

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

7 Replies

AD Administrator Syncfusion Team April 14, 2005 12:22 PM UTC

If I select several cells in, 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)

VI Vinay 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

AD Administrator Syncfusion Team 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.

VI Vinay 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

AD Administrator Syncfusion Team April 14, 2005 03:10 PM UTC

Try this code.
if (!e.Handled && e.KeyCode == Keys.Return && CurrentCell.IsEditing)
	e.Handled = true;

VI Vinay 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

AD Administrator Syncfusion Team 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)

Live Chat Icon For mobile
Up arrow icon