`
Par2: Sorting a listbox on header click 1999-04-13 -- Arnor Baldvinsson In response to a question on lists from queues: The code you need to sort, should be in the "NewSelection" embed on the tab sheet: Case Choice(?CurrentTab) Of 1 Sort(MyQueue,MyQueue.Field1) Of 2 Sort(MyQueue,MyQueue.Field2) Of 3 Sort(MyQueue,MyQueue.Field1) End You can also have the listbox change sort order by clicking on the header with some fairly simple code. 1. Alert the MouseLeft key on the listbox 2. Embed: Window event handling - PreAlertKey: Cycle 3. Embed: Window event handling - AlertKey: If ?List1{Proplist:MouseDownRow} = 0 ! Header Case ?List1{Proplist:MouseDownField} Of 1 Loc:Field = 1 Do ResortQueue Of 2 Loc:Field = 2 Do ResortQueue Of 3 Loc:Field = 3 Do ResortQueue End End 4. Embed: Procedure routines: ResortQueue ROUTINE Case Loc:Field Of 1 ! Keyword alphabetical Case Loc:SortOrder Of 1 Sort(Glo:ResultQ,+Glo:RQKeyword) Loc:SortOrder = 2 Of 2 Sort(Glo:ResultQ,-Glo:RQKeyword) Loc:SortOrder = 1 End Of 2 ! Word frequency Case Loc:SortOrder Of 1 Sort(Glo:ResultQ,+Glo:RQRelatedArticles) Loc:SortOrder = 2 Of 2 Sort(Glo:ResultQ,-Glo:RQRelatedArticles) Loc:SortOrder = 1 End Of 3 ! Word length Case Loc:SortOrder Of 1 Sort(Glo:ResultQ,+Glo:RQWordLength) Loc:SortOrder = 2 Of 2 Sort(Glo:ResultQ,-Glo:RQWordLength) Loc:SortOrder = 1 End End Display This toggles sort order of 3 fields in the queue when the user clicks on the listbox header. Printed November 23, 2024, 8:16 pm This article has been viewed/printed 35257 times. |