Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multi-selecting Prob w/ listbox with rowsource = 6 (Fiel
Message
From
08/07/2005 06:05:37
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
07/07/2005 13:02:42
Diran Nazarian
Alion Science and Technology
Annapolis, Maryland, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows 2000 SP4
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01030030
Message ID:
01030305
Views:
19
>I've tried that, and when I debug the gotfocus event it restores my items as expected. But once the gotfocus event is finished it deselects the items I restored and randomly selects items that it wants to.
>
>Here is my lostfocus and gotfocus code.
>
>LOSTFOCUS event:
>
>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
>
>
>GOTFOCUS event:
>
>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 = ""
>
>
>rc_selected is a Form property I created.

Couldn't check code in depth, probably only dodefault(),nodefault is missing.ie:
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
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform