J
Junkguy
I need some help programmatically causing a row in a DataGrid to "flush"
its contents to its bound data (in Visual Studio 6 using Windows Forms
with C#).
My issue is I want to send an update to a database from a menu command
while the user is editing a DataGrid. This is unusual in regard to
examples and normal practice in that the cell of the DataGrid still has
the focus. In all examples I can find, the user normally presses a
button on a Form. This practice causes the DataGrid to lose focus and
automatically flush the current row's contents to its bound data member.
But when I attempt to perform an update while the user is STILL editing
data in a row, the DataSet updates WITHOUT that particular row.
I attempted to circumvent this problem by simply setting the focus of
another control on the form (e.g. btnSave.Focus()), hoping that the
DataGrid would lose focus and flush its row contents to the DataSet, but
this proved to be inexplicably ineffective. The row was still not
flushed. I don't know if a Focus() call needs to iterate once through
the event chain before it finalizes or what.
I really want to do this the right way. I don't want to use a hack like
selecting another row before updating, but I can't find any method in
DataGrid that will force its contents to flush to its bound data. Does
anyone have the definitive procedure on this. Perhaps I'm simply missing
an obvious or well known method here?
its contents to its bound data (in Visual Studio 6 using Windows Forms
with C#).
My issue is I want to send an update to a database from a menu command
while the user is editing a DataGrid. This is unusual in regard to
examples and normal practice in that the cell of the DataGrid still has
the focus. In all examples I can find, the user normally presses a
button on a Form. This practice causes the DataGrid to lose focus and
automatically flush the current row's contents to its bound data member.
But when I attempt to perform an update while the user is STILL editing
data in a row, the DataSet updates WITHOUT that particular row.
I attempted to circumvent this problem by simply setting the focus of
another control on the form (e.g. btnSave.Focus()), hoping that the
DataGrid would lose focus and flush its row contents to the DataSet, but
this proved to be inexplicably ineffective. The row was still not
flushed. I don't know if a Focus() call needs to iterate once through
the event chain before it finalizes or what.
I really want to do this the right way. I don't want to use a hack like
selecting another row before updating, but I can't find any method in
DataGrid that will force its contents to flush to its bound data. Does
anyone have the definitive procedure on this. Perhaps I'm simply missing
an obvious or well known method here?