Home All Groups Group Topic Archive Search About

Remembering Sort Order on WinForms DataGrid

Author
30 Mar 2006 10:09 PM
Joseph Ferris
Hello,

Is it possible to retrieve and set the sort order for a DataGrid
control on a WinForm?  I had a user request this functionality, and I
can't seem to find a place to set and retrieve it from.  Am I missing
something, or is this something that is more difficult to do than is
worth the time?

Thanks in advance!

Joseph

Author
31 Mar 2006 8:07 AM
Cor Ligthert [MVP]
Joseph,

Your surely miss something because it is easy to do.

For that is the DataView or the DefaultView. Which is a view on a datatable.
In that DataView or Defaultview there is a property Sort. You can set that
while you can get the current value if a user changes that by clicking at
the top of the grid.

myDataTable.Defaultview.Sort = "MySecondColumn"

I hope this helps,

Cor

Show quoteHide quote
"Joseph Ferris" <joseph.fer***@gmail.com> schreef in bericht
news:1143756587.526480.325030@t31g2000cwb.googlegroups.com...
> Hello,
>
> Is it possible to retrieve and set the sort order for a DataGrid
> control on a WinForm?  I had a user request this functionality, and I
> can't seem to find a place to set and retrieve it from.  Am I missing
> something, or is this something that is more difficult to do than is
> worth the time?
>
> Thanks in advance!
>
> Joseph
>
Author
31 Mar 2006 10:01 AM
Joseph Ferris
Cor,

Yep.  Missed the obvious.  I knew that if I stepped away from it and
asked, it would save me a lot of aggrevation in the long run.

Thank you for helping me conserve what little hair I have left!

Joseph