You can select one or more Items.
You can select all items and you may Clear all items with 2 buttons.
Now I would like to modify this and force only one Item can be selected.
Like at each selection, it does a clear all prior selection.
Here is the code.
Code: Select all
FUNCTION sLISTBOX(aITEMS)
LOCAL GetList := {}, aFields:={}, cField:={}
LOCAL oListBox
aFields := aITEMS
@ 0,0 DCLISTBOX cField LIST aFields ;
FONT "10.Courier" ;
SIZE 15,10 ;
OBJECT oListBox
// SELECT {2,4,5,6,7}
@ 0, 17 DCPUSHBUTTON ;
CAPTION '~Mark All' ;
SIZE 10, 1.1 ;
FONT '8.MS Sans Serif' ;
ACTION {|| AEVAL(aFields, {|x,i| oListBox:setData(i, .T.)}), ;
DC_VarFromListBox(oListBox)} ;
RELATIVE oListBox
@ 1.5, 17 DCPUSHBUTTON ;
CAPTION 'C~lear All' ;
SIZE 10, 1.1 ;
FONT '8.MS Sans Serif' ;
ACTION {|| AEVAL(aFields, {|x,i| oListBox:setData(i, .F.)}), ;
DC_VarFromListBox(oListBox)} ;
RELATIVE oListBox
DCREAD GUI ;
TITLE 'Select Multiple' ;
FIT ;
ADDBUTTONS ;
MODAL
// DC_MsgBox(cField)
RETURN cField
Code: Select all
@ 0, 17 DCPUSHBUTTON ;
CAPTION '~Mark All' ;
SIZE 10, 1.1 ;
FONT '8.MS Sans Serif' ;
ACTION {|| AEVAL(aFields, {|x,i| oListBox:setData(i, .T.)}), ;
DC_VarFromListBox(oListBox)} ;
RELATIVE oListBox
@ 1.5, 17 DCPUSHBUTTON ;
CAPTION 'C~lear All' ;
SIZE 10, 1.1 ;
FONT '8.MS Sans Serif' ;
ACTION {|| AEVAL(aFields, {|x,i| oListBox:setData(i, .F.)}), ;
DC_VarFromListBox(oListBox)} ;
RELATIVE oListBox
Clear all
Select the Item clicked.
Code: Select all
ACTION {|| AEVAL(aFields, {|x,i| oListBox:setData(i, .F.)}), ;
DC_VarFromListBox(oListBox)} ;