From: Patrick A on
All,

When I save datagridview record changes, should the current sort
column and order save?

I have a datagridview I placed onto a form, and it is "fed" without
any sorting from a DB (bound datasource).

Changes to any cell in the datagridview save just fine, but if the
user sorts the datagridview by clicking on a column (as they like to
do), that does not save/update the DB. (And does not persist from
session to session.)

Is this by design?

If not, any suggstions as to what to verify or enable to make it work?

If so, any suggestions as to how I might code around this? Users want
sort to stay sorted, and some other parts of my app re-purpose the
data, which should also appear in the sorted order.

Thanks,

Patrick
From: Andrew Morton on
Patrick A wrote:
> When I save datagridview record changes, should the current sort
> column and order save?

Only if you save the current sort column and order somewhere and then sort
on that column automatically the next time a user retrieves that data. You
may want to do thar on a per-user basis.

The other parts of your app will have to use the saved sort column/order
too.

Data in a database are not inherently ordered in any way: {1,2,3,4} is the
same as {2,3,1,4} in a database because it is set-based. It is only when you
select data that you can choose an order for it.

HTH,

Andrew


From: Patrick A on
Thanks Andrew!

I can save it on a per user basis, so that's no problem.

I like that it then becomes available elsewhere - I had not thought of
that.

I should also be able to save it to an ini file for use the next time
the user opens the app, correct?

(Just thinking out loud before breakfast.)

Patrick

On Mar 26, 4:57 am, "Andrew Morton" <a...(a)in-press.co.uk.invalid>
wrote:
> Patrick A wrote:
> > When I save datagridview record changes, should the current sort
> > column and order save?
>
> Only if you save the current sort column and order somewhere and then sort
> on that column automatically the next time a user retrieves that data. You
> may want to do thar on a per-user basis.
>
> The other parts of your app will have to use the saved sort column/order
> too.
>
> Data in a database are not inherently ordered in any way: {1,2,3,4} is the
> same as {2,3,1,4} in a database because it is set-based. It is only when you
> select data that you can choose an order for it.
>
> HTH,
>
> Andrew

From: Andrew Morton on
Patrick A wrote:
> I can save it on a per user basis, so that's no problem.
>
> I like that it then becomes available elsewhere - I had not thought of
> that.
>
> I should also be able to save it to an ini file for use the next time
> the user opens the app, correct?

Presumably the database is (physically) the same one for all the users, so
it may make more sense to save it there rather than locally. That way, if
they log in (as themselves) on other computers, they will still have the
same state even if they don't have roaming profiles.

Andrew


From: Patrick A on
Andrew,

Actually, the DB is a different one for all users. (It's a 200K MDB
file.) It is stored on their "H:" drive, a networked drive that maps
as the same letter wherever they log in.

But yes, I can write the value there or in the ini file, which is also
stored on their "H:" drive.


storyOn Mar 26, 7:57 am, "Andrew Morton" <a...(a)in-press.co.uk.invalid>
wrote:
> Patrick A wrote:
> > I can save it on a per user basis, so that's no problem.
>
> > I like that it then becomes available elsewhere - I had not thought of
> > that.
>
> > I should also be able to save it to an ini file for use the next time
> > the user opens the app, correct?
>
> Presumably the database is (physically) the same one for all the users, so
> it may make more sense to save it there rather than locally. That way, if
> they log in (as themselves) on other computers, they will still have the
> same state even if they don't have roaming profiles.
>
> Andrew