INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

ListBox

Programmatically Loading & Referencing Listbox Items by jimoo
Posted: 19 Oct 03 (Edited 21 Oct 03)

1. Create a new form and add a listbox.
2. Set ColumnCount = 3
3. Set ColumnWidths to 110,110,110
4. Put the following code in FORM init Event:

FOR lni = 1 TO 3
    DO CASE
    CASE lni = 1
        lcValue = "Mickey"
    CASE lni = 2
        lcValue = "Donald"
    OTHERWISE
        lcValue = "Goofey"
    ENDCASE    

    THISFORM.list1.ADDLISTITEM(lcValue + " A ",lni,1)
    THISFORM.list1.ADDLISTITEM(lcValue + " B ",lni,2)
    THISFORM.list1.ADDLISTITEM(lcValue + " C ",lni,3)
ENDFOR

5. Add a button
6. Place the following code in the click event of the button:


FOR lni = 1 TO THISFORM.list1.LISTCOUNT
    MESSAGEBOX(THISFORM.list1.LISTITEM(lni,1))
    MESSAGEBOX(THISFORM.list1.LISTITEM(lni,2))
    MESSAGEBOX(THISFORM.list1.LISTITEM(lni,3))
ENDFOR

THISFORM.RELEASE

7. Save and execute the form.

This demonstrates how you can programmatically load the items, and then reference them individually.  

If you would like to see how to take the multi-column list items from this item, and move them to another multi-column list continue with step 8.

8. Add another listbox to the form.  It probably has the name of list2.

9. In the double-click event of list1, add the following code:

lnList2Count = THISFORM.list2.ListCount + 1

THISFORM.List2.ADDLISTITEM(this.List(this.listindex,1),lnList2Count,1)
THISFORM.List2.ADDLISTITEM(this.List(this.listindex,2),lnList2Count,2)
THISFORM.List2.ADDLISTITEM(this.List(this.listindex,3),lnList2Count,3)

This.RemoveItem(This.ListIndex)

10. Size list boxes, save & run code.

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close