List Box Select Only One
Posted: Fri Oct 14, 2016 6:34 am
I have this code that show Items in a List Box.
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.
I need to remove this
But, I need to do this action every time I click on one Item.
Clear all
Select the Item clicked.
Thanks for your help.
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)} ;