Ideas on How to handle datagrid update

R

Randy

Hello All,
I'm trying to discover the best way to handle the situation where you have a
datagrid in your app and someone changes a cell but doesn't leave that cell
(so there's the little pencil icon on the left margin of the datagrid) and
then the user clicks a menu to save the data in the datagrid. You see, my
problem is that at this point, the table attached to the datagrid hasn't
been updated because the user never left the cell they changed of the
datagrid. Is there a way to update the table attached to the datasource when
the datagrid looses focus? Maybe switching rows in the datagrid when it
looses focus would make the datagrid update to the table?
Thanks for any input...

Cheers :)
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hello Randy,

The following has worked for me:

1. Call EndEdit() on the grid.
2. Obtain a CurrencyManager instance for the grid through the form's
BindingContext property and call EndCurrentEdit() on that instance.

Step 2 ensures the row state in the bound table will be set to
added/modified, as the step 1 only pushes the data but does not update the
row state.
 
R

Randy

Thanks Dmitriy, works like a charm...

Dmitriy Lapshin said:
Hello Randy,

The following has worked for me:

1. Call EndEdit() on the grid.
2. Obtain a CurrencyManager instance for the grid through the form's
BindingContext property and call EndCurrentEdit() on that instance.

Step 2 ensures the row state in the bound table will be set to
added/modified, as the step 1 only pushes the data but does not update the
row state.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Randy said:
Hello All,
I'm trying to discover the best way to handle the situation where you
have
a
datagrid in your app and someone changes a cell but doesn't leave that cell
(so there's the little pencil icon on the left margin of the datagrid) and
then the user clicks a menu to save the data in the datagrid. You see, my
problem is that at this point, the table attached to the datagrid hasn't
been updated because the user never left the cell they changed of the
datagrid. Is there a way to update the table attached to the datasource when
the datagrid looses focus? Maybe switching rows in the datagrid when it
looses focus would make the datagrid update to the table?
Thanks for any input...

Cheers :)
 

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