Results 1 to 5 of 5

Thread: clear a filelistbox

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    clear a filelistbox

    I have a filelistbox that displays files inside a specific folder when the user clicks on the command check.what I want is to clear the content of the filelistbox each time the user clicks on check

    Private Sub cmdCheck_click()

    File1.clear 'It didn't work

    ...'My code

    File1.Path="C:\TempProject"

    How can I clear a filelistbox?
    thanks

  2. #2
    Hyperactive Member
    Join Date
    Feb 2003
    Location
    Grenada
    Posts
    346

    Re: clear a filelistbox

    BASICALLY it's impossible from what I know... unless I'm mistaken and someone else possess the know how.

    You MAY be able to clear it by sobclassing the window and sending the necessary command. But that in itself may prove difficult only to disappoint you in the end.

    My suggestion is to simple hide the file listbox behind a picture box designed to look like the filelist box (Back color white, 3D effects, matching dimensions... blah blah blah)

    Understand?
    If my post has been helpful, then please rate it accordingly...
    If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.

  3. #3
    New Member
    Join Date
    Apr 2006
    Posts
    10

    Re: clear a filelistbox

    Hi,
    Just set the file1.pattern to peculiar(which won't exist normally,for eg : like file1.pattern="$$.$$") one,So that it will not display any files/folders.

    Try it once.

  4. #4
    Addicted Member
    Join Date
    Apr 2006
    Posts
    155

    Re: clear a filelistbox

    Or you can make a ListBox control and just copy everything from the FileListBox control into ListBox and then you can clear it.

  5. #5
    Addicted Member
    Join Date
    Apr 2006
    Location
    USA
    Posts
    207

    Re: clear a filelistbox

    I have to agree. You can't "clear" a FileListBox. If you want to just remove a selected filename each time the cmdCheck is clicked then you can do as XRsTX suggested.

    Copy the filelist to a listbox and use List1.RemoveItem (List1.ListIndex)

    Here's an example using command1 , file1 and list1
    VB Code:
    1. Private Sub Form_Load()
    2.     Dim i As Integer
    3.     For i = 0 To File1.ListCount - 1
    4.         List1.AddItem File1.List(i)
    5.     Next i
    6. End Sub
    7.  
    8.  
    9. Private Sub Command1_Click()
    10.     If List1.ListIndex = -1 Then Exit Sub
    11.    
    12.     List1.RemoveItem (List1.ListIndex)
    13. End Sub
    If clicking on the commandbutton is deleting or moving the file then use file1.Refresh to update the filelist.
    Keith_VB6

    If you have any further questions, just ask.
    If this solves things, then please mark the thread resolved.
    [Thread Tools] --> [Mark Thread Resolved]

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