There are many programmers who like to provide a combobox to change the sort order additionally. In this case, programmers are often facing difficulty in perfectly synchronizing the combobox and the built-in sort by clicking the header.
This process is extremely simplified by introducing oBrw:oSortCbx and internally managing the combobox.
There are two ways of creating:
Method-1: Recommended
- Code: Select all Expand view
// after creating the browse and calling oBrw:CreatefromCode()
@ r,c COMBOBOX oBrw:oComboCbx VAR oBrwL:cSortOrder SIZE w,h PIXEL OF oDlg/oWnd/oBar
Rest is fully taken care of by the XBrowse.
Method-2: This method also works
- Code: Select all Expand view
local cOrder := ""
@ r,c COMBOBOX oCbx VAR cOrder SIZE w,h PIXEL OF oDlg/oWnd/oBar
@ r,c XBROWSE oBrw ........... DATASOURCE <src> .........
...
oBrw:oSortCbx := oCbx
oBrw:CreateFromCode()
This is a sample program:
- Code: Select all Expand view
- #include "fivewin.ch"
REQUEST DBFCDX
function Main()
local oDlg, oBrw
USE CUSTOMER NEW VIA "DBFCDX"
SET ORDER TO TAG FIRST
GO TOP
DEFINE DIALOG oDlg SIZE 800,400 PIXEL TRUEPIXEL RESIZABLE
@ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE ALIAS() AUTOCOLS AUTOSORT ;
CELL LINES NOBORDER
oBrw:CreateFromCode()
@ 10,20 COMBOBOX oBrw:oSortCbx VAR oBrw:cSortOrder SIZE 100,400 PIXEL OF oDlg
ACTIVATE DIALOG oDlg CENTERED
return nil