Article ID: 148724
Article Last Modified on 2/12/2007
aSelected(1)Again choose New Property from the Form menu. Enter the variable that will be used to count the selected items in the name box. Then click OK:
nCount
** Activate event:
Thisform.nCount=0 && Reset nCount when page is selected
Thisform.aSelected=" " && Reinitialize array to empty string
DIMENSION Thisform.aSelected(1) && Redimension array to one element
FOR i=1 TO This.List1.ListCount && Loop through number items in List
IF This.List1.Selected=.T. && If an item is selected in List,
This.List1.Selected=.F. && the Selected property is .T.
ENDIF
ENDFOR
This.List1.ListIndex=0 && Reset the index number of List box
This.List1.RowSource=This.List1.RowSource
This.Refresh && Force List and Form to refresh
** Deactivate event:
This.Command1.Enabled=.F.
LOCAL narraycnt
narraycnt=1
FOR i=1 TO This.List1.ListCount && Loop through Selected array, if
IF This.List1.Selected(i)=.T. && true, increment nCount variable.
Thisform.nCount=Thisform.nCount+1
ENDIF
ENDFOR
IF Thisform.nCount=0 && No selection made, set nCount=1
Thisform.nCount=1
Thisform.aSelected(Thisform.nCount)="No Selection Made!"
ENDIF
DIMENSION Thisform.aSelected(Thisform.nCount) && Dimension array
FOR i=1 TO This.List1.Listcount && Loop through items in List,
IF This.List1.Selected(i)=.T. && if Selected-look at List property
Thisform.aSelected(narraycnt)=This.List1.List(i)
narraycnt=narraycnt+1
ENDIF
ENDFOR
RowSource - Enter the following on one, single line:
SELECT DISTINCT Employee.Title from Testdata!Employee ORDER BY
Employee.Title INTO CURSOR mlist WHERE NOT EMPTY(Employee.Title)
RowSourceType: 3 - SQL Statement
MultiSelect: .T.
Click Event:
This.Parent.Command1.Enabled=.T. && Enable 'RESET' button
Caption: Reset List ** Click Event: This.Parent.List1.ListIndex=0 && Reset ListIndex property This.Parent.List1.RowSource=This.Parent.List1.RowSource This.Parent.Refresh && Refresh List and Page This.Enabled=.F. && Disable 'RESET' button This.Parent.List1.Setfocus && Put focus on list
** Activate event:
This.List1.Requery && Issue Requery to display/refresh
RowSource: Thisform.aSelected
RowSourceType: 5 - Array
Additional query words: VFoxWin listbox multiselect listcount selected list
Keywords: kbcode KB148724