S
susan
I have a Windows Form written in C# with a non-edit DataGrid showing a
list of records. When the user selects a row in the grid, the full
details of the record display in a panel which contains textboxes and
comboboxes. The underlying datatable that the detail panel is bound to
only ever has one record at a given time.
When the user edits the detail record and then issues a save command by
clicking the save button, all works well. This is because the focus
moves from the current control and current record to the button.
However if the user issues a Save by pressing the F2 key (caught by the
form's ProcessCmdKey), the focus remains in the current control and
current record. Under these circumstances, the EndCurrentEdit will not
push the changes into the dataset.
I tried calling EndCurrentEdit() on each control (in the control leave
event) in the following ways:
control.BindingContext[dataset.Tables[datatablename]].EndCurrentEdit();
if (control.DataBindings.Count > 0)
{
control.DataBindings[0].BindingManagerBase.EndCurrentEdit();
}
I tried calling EndEdit() on the datatable row
dataset.Tables[datatablename].Rows[rownumber].EndEdit()
I then implemented a BindingManagerBase as follows:
bindMgrBase = this.BindingContext [mydataset, datatablename];
and on save called
bindMgrBase.EndCurrentEdit()
I tried
1) moving programmatically to the next textbox control
2) moving programmatically back to the datagrid
3) moving programmatically to a button
I suspect that the EndCurrentEdit() requires the user to move off the
current record. That is difficult to test as the record detail panel
only ever has one record at a given time.
Is there any way to make this work? Anyone have any ideas for me?
....Susan
list of records. When the user selects a row in the grid, the full
details of the record display in a panel which contains textboxes and
comboboxes. The underlying datatable that the detail panel is bound to
only ever has one record at a given time.
When the user edits the detail record and then issues a save command by
clicking the save button, all works well. This is because the focus
moves from the current control and current record to the button.
However if the user issues a Save by pressing the F2 key (caught by the
form's ProcessCmdKey), the focus remains in the current control and
current record. Under these circumstances, the EndCurrentEdit will not
push the changes into the dataset.
I tried calling EndCurrentEdit() on each control (in the control leave
event) in the following ways:
control.BindingContext[dataset.Tables[datatablename]].EndCurrentEdit();
if (control.DataBindings.Count > 0)
{
control.DataBindings[0].BindingManagerBase.EndCurrentEdit();
}
I tried calling EndEdit() on the datatable row
dataset.Tables[datatablename].Rows[rownumber].EndEdit()
I then implemented a BindingManagerBase as follows:
bindMgrBase = this.BindingContext [mydataset, datatablename];
and on save called
bindMgrBase.EndCurrentEdit()
I tried
1) moving programmatically to the next textbox control
2) moving programmatically back to the datagrid
3) moving programmatically to a button
I suspect that the EndCurrentEdit() requires the user to move off the
current record. That is difficult to test as the record detail panel
only ever has one record at a given time.
Is there any way to make this work? Anyone have any ideas for me?
....Susan