Hello Lee, Milio propose this change to avoid the arrows appear upside than sorting. Instead of: ValueSorted.Sort(GridView1.Columns.Ascending) this code: If GridView1.Columns.Ascending Then ValueSorted.Sort(gb.Ascent) Else ValueSorted.Sort(gb.Descent) Endif Regards Gianluigi
2016-04-01 10:32 GMT+02:00 Gianluigi <bagone...@gmail.com>: > Hello Lee, > thank you (also from my teacher Milio :-) ), all is a perfect explanation. > > Regards > Gianluigi > > 2016-04-01 2:21 GMT+02:00 T Lee Davidson <t.lee.david...@gmail.com>: > >> That's exactly what I needed, Gianluigi. Thank you. >> >> It works well even preserving distinct rows with duplicate key values. >> >> I added a few comments to your code and added it as an example to >> http://gambaswiki.org/wiki/comp/gb.qt4/gridview/sorted. (I >> hope that's okay with you. If not, please let me know and I'll modify or >> remove it.) >> >> >> -- >> Lee >> __________ >> >> "Artificial Intelligence is no match for natural stupidity." >> >> >> On 03/31/2016 04:51 AM, Gianluigi wrote: >> > 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 >> >> >> ------------------------------------------------------------------------------ >> 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 >> > > ------------------------------------------------------------------------------ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user