[Gambas-user] ColumnView Sorting

MinnesotaJon nicholso at ...2533...
Sun Nov 17 02:46:12 CET 2013


Hi, Nigel --

I've never used the ColumnView (or other View) to sort the data -- I always
sort the arrays where I keep data, and then re-fill the ColumnView or other
View, if necessary.  Your question raised a point that I've never explored,
so I dug into it and found that you CAN sort data in a View, using the
built-in capabilities of the View object.  The documentation is on this
page:
http://gambasdoc.org/help/comp/gb.qt4/_columnview_columns?v3

Frankly, I sometimes find the Gambas online documentation to be a little
cryptic, so (like usual) I wrote a simple program to explore and demonstrate
sorting in a ColumnView.  Here is the essential code block, especially note
the inner/2nd "If-Endif" block:

'Note that when you change the sort of the ColumnView from one column to
another,
'the sort column header will display a down-arrow symbol.
Public Sub Button1_Click() 
  If TextBox1.Text  'In other words, if TextBox1.Text is not NULL.
    If TextBox1.Text = "0" Or If TextBox1.Text = "1" Or If TextBox1.Text =
"2" Then
      ColumnView1.Columns.Ascending = True
      ColumnView1.Columns.Sort = Val(TextBox1.Text)
    Else
      Message.Info("Type a Column ID: '0','1', or '2'", "OK")
      TextBox1.Text = ""
    Endif
  Else
    Message.Info("Type a Column ID: '0','1', or '2'", "OK")
    TextBox1.Text = ""
  Endif
End

My e-mail address is:  nicholso at ...2533...
If you send me your e-mail address, I'll send you a tar.gz file of the
complete program, just so you can play with it and see how the sort works. 

Best regards,

Jon Nicholson



--
View this message in context: http://gambas.8142.n7.nabble.com/ColumnView-Sorting-tp44263p44279.html
Sent from the gambas-user mailing list archive at Nabble.com.




More information about the User mailing list