Remembering Sort Order on WinForms DataGrid

  • Thread starter Thread starter Joseph Ferris
  • Start date Start date
J

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
 
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
 
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
 

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

Back
Top