Without using the database, have taught me so: Public Sub TableView1_Sort() Dim Values, ValueSorted As New String[] Dim Nx, iNx As Integer Dim tmp As String
For Nx = 0 To TableView1.Rows.Max Values.Add(TableView1[Nx, TableView1.Columns.Sort].Text) Next ValueSorted = Values.Copy() ValueSorted.Sort(TableView1.Columns.Ascending) For Nx = 0 To ValueSorted.Max For iNx = 0 To TableView1.Columns.Max Swap TableView1[Nx, iNx].Text, TableView1[Values.Find(ValueSorted[Nx], 0, Nx), iNx].Text Next Values.Clear() For iNx = 0 To TableView1.Rows.Max Values.Add(TableView1[iNx, TableView1.Columns.Sort].Text) Next Next TableView1.Refresh() End Regards Gianluigi 2016-03-31 2:33 GMT+02:00 T Lee Davidson <t.lee.david...@gmail.com>: > Thank you for your effort, Gianluigi. But, I am not using a database; just > a TableView of data. > > When a TableView's Sorted property is set to True, clicking on a column > header toggles the sort indicator and raises the > TableView's Sort event. > > I need to sort the TableView rows based on the values in whichever column > the header was clicked. > > > On 03/30/2016 06:06 PM, Gianluigi wrote: > > Not sure if I understand the question, but something like that, could > help? > > > > If TableView1.Columns.Ascending Then > > sMySql = "SELECT *" > > sMySql &= " FROM customers" > > sMySql &= " ORDER BY surname ASC," > > sMySql &= " name ASC" > > sMySql &= ";" > > Else > > sMySql = "SELECT *" > > sMySql &= " FROM customers" > > sMySql &= " ORDER BY surname DESC," > > sMySql &= " name DESC" > > sMySql &= ";" > > Endif > > > > Regards > > Gianluigi > > > > 2016-03-30 22:18 GMT+02:00 T Lee Davidson <t.lee.david...@gmail.com>: > > > >> The documentation for TableView shows a Sorted property which says, > >> "Sorting the data is not done automatically. It must be done > >> by user code." But, the page does not give any clues regarding how to > >> accomplish that. Though, obviously, sorting should be done > >> in the Sort event handler. > >> > >> In the past, I have used an array of objects to store the data > represented > >> in the TableView. This provided use of Object[].Sort > >> with the _compare function. > >> > >> This time around, I am attempting to eliminate the redundancy of > duplicate > >> data containers (store and view) and the cumbersome > >> syncing of the data and the view. (Perhaps I should just simply use a > >> SQLite DB and a DataView?) > >> > >> There appears to be no TableView/GridView or GridView.Columns Sort > method. > >> > >> Does anyone have any hints as to how to sort a TableView? > >> > >> > >> -- > >> Lee > >> __________ > >> > >> "Artificial Intelligence is no match for natural stupidity." > >> > >> > >> > ------------------------------------------------------------------------------ > >> Transform Data into Opportunity. > >> Accelerate data analysis in your applications with > >> Intel Data Analytics Acceleration Library. > >> Click to learn more. > >> http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140 > >> _______________________________________________ > >> Gambas-user mailing list > >> Gambas-user@lists.sourceforge.net > >> https://lists.sourceforge.net/lists/listinfo/gambas-user > >> > > > ------------------------------------------------------------------------------ > > Transform Data into Opportunity. > > Accelerate data analysis in your applications with > > Intel Data Analytics Acceleration Library. > > Click to learn more. > > http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140 > > _______________________________________________ > > Gambas-user mailing list > > Gambas-user@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/gambas-user > > > > -- > Lee > __________ > > "Artificial Intelligence is no match for natural stupidity." > > > ------------------------------------------------------------------------------ > Transform Data into Opportunity. > Accelerate data analysis in your applications with > Intel Data Analytics Acceleration Library. > Click to learn more. > http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140 > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------------ Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140 _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user