I am in edit mode of the GRID control, when user enters a value in a cell and clicks on Apply button, the value of the current cell is not available in the Apply button method? What should I do to commit changes for the edited cell?
Thanks
AD
Administrator
Syncfusion Team
October 29, 2005 10:44 PM UTC
Try calling
grid.CurrentCell.CommitChanges();
in a GridControl. You can also try calling grid.CurrentCel.EndEdit().
In a GridDataBoundGrid, in addition to the above, you might need to call grid.Binder.EndEdit().
AD
Administrator
Syncfusion Team
November 11, 2005 06:11 PM UTC
hi,
I have the same problem with a GDBG.
I changed the value of a cell. But after pressing the ENTER-Key, the new value is not available in the datasource (a datatable).
I tried grid.Binder.EndEdit, grid.BindingContext[datasource].EndCurrentEdit(), but that all had no effect.
But after editing the neighbor-cell (Checkbox-cell) the value in the textbox-cell is also available in the datasource.
Is this a bug? :-/
AD
Administrator
Syncfusion Team
November 11, 2005 06:55 PM UTC
The default behavior of the GriddataBoundGrid is to only save the modified record when you leave the grid row. This is by design.
Here are some more things to try in your case.
1) Try setting grid.Binder.DirectSaveCellInfo = true when you initially set up the grid to see if this will make things work the way you want them to.
2)
grid.Currentcell.EndEdit();
grid.BindingContext[grid.DataSource, grid.DataMember].EndCurrentEdit();
AD
Administrator
Syncfusion Team
November 12, 2005 08:18 AM UTC
Hi,
the grid.Binder.DirectSaveCellInfo = true has no effect.
If I call grid.CurrentCell.EndEdit() in the ...CurrentCellValidated - event, this will cause a stackoverflowError (because the ...CurrentCellValidated is called again).
Also your last proposal has no effect.
AD
Administrator
Syncfusion Team
November 12, 2005 09:34 AM UTC
You can avoid the stack overflow by using a flag. Or, you could try a different event like CurrentCellMoved.
Can you upload a sample showing the problem you are having?
AD
Administrator
Syncfusion Team
November 12, 2005 10:41 AM UTC
Hi,
here is a small sample-application.
Do the following:
Set a stop-point to the currentcellvalidated-eventhandler, start the app. and change the value (e. g. in the last record), press enter and watch the value in the table.
Greetings
Falk
GDBGProblemSample.zip
AD
Administrator
Syncfusion Team
November 12, 2005 10:54 AM UTC
Here is code that worked for me in your sample(without using DirectCellSaveInfo).
bool inCellValidated = false;
private void gridDataBoundGrid1_CurrentCellValidated(object sender, System.EventArgs e) {
if(!inCellValidated)
{
inCellValidated = true;
this.gridDataBoundGrid1.CurrentCell.EndEdit();
gridDataBoundGrid1.Binder.EndEdit();
inCellValidated = false;
//check value - code not needed
CurrencyManager cm = gridDataBoundGrid1.BindingContext[gridDataBoundGrid1.DataSource] as CurrencyManager;
DataRowView drv = cm.Current as DataRowView;
Console.WriteLine(drv["VALUE"]);
}
}
AD
Administrator
Syncfusion Team
November 12, 2005 12:17 PM UTC
Yes, this works,
but it''s a pity that a workaround is necessary;
Thank you
Greetings
Falk
AD
Administrator
Syncfusion Team
November 12, 2005 12:24 PM UTC
It is your choice of events that is why you need the code. In CurrentCellValidated, you know the value is ok, but it is not been saved by the cuurentcell yet.
Try using CurrentCellAcceptedChanges. At that point, the currentcell has comittted its changes.
AD
Administrator
Syncfusion Team
November 13, 2005 05:54 PM UTC
Ah - that''s it!
This is what I''m looking for!
Thank you very much!
Greetings
Falk
AD
Administrator
Syncfusion Team
November 17, 2005 07:35 PM UTC
Sorry - it''s me again. I was wrong: it is still not working. (I don''t know how I could think so)!
The CurrentCellAcceptedChanges-event is fired to late.
I''m looking for the following behavior:
I want to check a bool-value (Checkbox) in a GDBDGD. Immediately after checking the new value must be written to the table and in the next step the table-changes must be written to the database (an update - just on moving the mousebutton up).
At this time the update is done by leaving the grid or editing another cell.
Sorry for my hardheadedness - but I need this behavior.
Falk
AD
Administrator
Syncfusion Team
November 17, 2005 07:56 PM UTC
Try handling the grid.CheckBoxClick event. There call grid.Binder.EndEdit.