Maintaining a ReportView Column Sort

Started by chrislegarth, March 28, 2018, 02:27:02 PM

Previous topic - Next topic

chrislegarth

I have a form that has a ReportView displaying 13 columns of data.  I have code that will sort the columns ASC or DESC when the column header is pressed.
What I'd like to know and can't seem to figure out is is there a way to maintain the last column sort and direction after the ReportView is updated with new data.
The ReportView defaults back to sorting the first column ASC.  If necessary, I can post a sample ReportView as an example.

Any help would be appreciated.
Thanks!

td

If you are using an array to load your data you could use DialogControlState to remove the sort style, presort your input array using ArraySort on the last column, reload the control and then re-enable the sort style.


Code (winbatch) Select
; a2 is a new presorted array.
nSortStyle = @csAsort
DialogControlState(MyDialog_Handle, "ReportView_1", @dcsRemStyle, nSortStyle)           
DialogControlSet(MyDialog_Handle,"ReportView_1",@dcContents, a2)
DialogControlState(MyDialog_Handle, "ReportView_1", @dcsAddStyle, nSortStyle)
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

chrislegarth

Thanks!  I didn't think about sorting the array directly.  It worked perfectly!