|
-
Apr 29th, 2006, 01:18 AM
#1
Thread Starter
Fanatic Member
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
-
Apr 29th, 2006, 01:26 AM
#2
Hyperactive Member
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.
-
Apr 29th, 2006, 02:05 AM
#3
New Member
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.
-
Apr 29th, 2006, 10:33 AM
#4
Addicted Member
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.
-
Apr 29th, 2006, 08:32 PM
#5
Addicted Member
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:
Private Sub Form_Load()
Dim i As Integer
For i = 0 To File1.ListCount - 1
List1.AddItem File1.List(i)
Next i
End Sub
Private Sub Command1_Click()
If List1.ListIndex = -1 Then Exit Sub
List1.RemoveItem (List1.ListIndex)
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|