DataGrid and catching changes on Leave

I

Iain

I have a data grid. It is databound to a DataSet which is a kind of
CrossTab.

I allow the user to make a change to a cell and when they leave the cell I
update the database.

This all works nicely.

EXCEPT (you knew there was a gotcha!). If I mouse out of the datagrid to
another column, the DataGrid[x, y] has not been updated. It updates
later,but by that time it's too late for me and I've likely reloaded the
data from another result set.

I've tried catching Leave and Validated, but in both cases the value of the
Cell is the original one not the one I've typed in.

If I move around within the grid it all works nicely thank you.

My next thing to try is to find the contents of the text box, but this all
seems too hard. Am I missing something obvious?

Iain
 
G

Guest

I have this hooked into the leave event in all of my datagrids(that use a currency manager) so that any typing left in a
cell gets taken into account as opposed to being ignored..

private void dataGrid_Leave_UpDate_Cell(object sender, System.EventArgs e

if ( dataGrid.EndEdit( null, dataGrid.CurrentRowIndex, false )

((CurrencyManager) dataGrid.BindingContex
[dataGrid.DataSource, dataGrid.DataMember
).EndCurrentEdit()

}
 
I

Iain

Works a treat, thank you.

Iain
Mike in Paradise said:
I have this hooked into the leave event in all of my datagrids(that use a
currency manager) so that any typing left in a
cell gets taken into account as opposed to being ignored...

private void dataGrid_Leave_UpDate_Cell(object sender, System.EventArgs e)
{
if ( dataGrid.EndEdit( null, dataGrid.CurrentRowIndex, false ))
{
((CurrencyManager) dataGrid.BindingContext
[dataGrid.DataSource, dataGrid.DataMember ]
).EndCurrentEdit();
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top