CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: FileListBox

  1. #1
    Join Date
    May 2001
    Posts
    3

    FileListBox

    I have setup a filelistbox that allows multiple selections. How do I view each selection in the code (i.e. File1.FileName just shows me the last selection, I want all selected items. File1.Selected (#) just tells me if that number was selected.) I assume I could write a for loop that checks if each item was selected and stick the results in an array, but I figure there has to be an easier way.

    Thanks,
    Quad


  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: FileListBox

    Isn't that easy enough?


  3. #3
    Join Date
    May 2001
    Posts
    3

    Re: FileListBox

    If that is the only option, but I hate to do excess processing when it could be a property array of the component.


  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: FileListBox

    From msdn:

    Private Sub Form_Load ()
    Dim I ' Declare variable.
    ' Fill the list box with screen font names.
    For I = 0 To Screen.FontCount - 1
    List1.AddItem Screen.Fonts(I)
    Next I
    End Sub

    Private Sub Command1_Click ()
    Dim I ' Declare variable.
    ' Clear all items from the list.
    List2.Clear
    ' If an item is selected, add it to List2.
    For I = 0 To List1.ListCount - 1
    If List1.Selected(I) Then
    List2.AddItem List1.List(I)
    End If
    Next I
    End Sub



    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167

    Re: FileListBox

    Nope, that is the easiest way and the only way

    -Cool Bizs

    Good Luck,
    -Cool Bizs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured