>LOCAL lc_indexno >LOCAL ln_loop > >lc_indexno = "" > >FOR ln_loop = 1 TO THIS.LISTCOUNT > > IF THIS.SELECTED(ln_loop) > lc_indexno = ALLTRIM(STR(ln_loop)) > THISFORM.rc_selected = ALLTRIM(THISFORM.rc_selected) + lc_indexno + "," > ENDIF > >ENDFOR >>
>LOCAL ln_pos >LOCAL lc_item >LOCAL ln_strlen >LOCAL lc_newstring >LOCAL ln_clrcnt >LOCAL ln_loop > >lc_main = THISFORM.rc_selected >lc_new = lc_main >ln_strlen = LEN(lc_new) > >*!* Clear the list of any selected items. >FOR ln_clrcnt = 1 TO THIS.LISTCOUNT > THIS.SELECTED(ln_clrcnt) = .F. >ENDFOR > >*!* Select the items that the user chose before losing focus. >DO WHILE ln_strlen > 0 > ln_pos = AT(",",lc_new) > IF ln_pos >1 > lc_item = SUBSTR(lc_new,1,ln_pos-1) > THIS.SELECTED(VAL(lc_item)) = .T. > lc_new = SUBSTR(lc_new,ln_pos+1) > ln_strlen = LEN(lc_new) > ENDIF >ENDDO > >*!* reset the selected property value. >THISFORM.rc_selected = "" >>
Public oForm oForm = Createobject('myForm') oForm.Show Define Class myForm As Form DataSession = 2 Height=400 Width =400 Add Object txtDummy1 As TextBox With Top=10,Left=10 Add Object myListBox As ListBox With ; Top=50,Left=10,Height=300,Width=380,; RowSourceType=6,; RowSource='customer.contact,company,cust_id',; ColumnCount=3,; ColumnWidths='100,200,50',; MultiSelect=.T. Add Object txtDummy2 As TextBox With Top=360,Left=10 Procedure Load Use customer Endproc Procedure myListBox.Init This.AddProperty('aSelected[1]') Endproc Procedure myListBox.GotFocus DoDefault() Nodefault With This For ix=1 To Alen(.aSelected) .Selected(m.ix) = .aSelected[m.ix] Endfor Endwith Endproc Procedure myListBox.LostFocus With This Dimension .aSelected[.ListCount] For ix=1 To .ListCount .aSelected[m.ix] = .Selected(m.ix) Endfor Endwith Endproc EnddefineCetin