Click to See Complete Forum and Search --> : Get num files of FileListBox,DirectoryListBox


Leite33
September 16th, 2006, 03:51 PM
Hi.
I made a windows explorer in BCB6. I want some code to display the number of folders and files at statusbar. I Connect FileListBox and DirectoryListBox. Any code ideas?Where i will put the code?In what event?

ncode
September 19th, 2006, 10:30 AM
TFileListBox derived from TCustomListBox, so you can use it`s methods as follows:

TFileListBox* flb = new TFileListBox();
...
int FilesCount = flb->Items->Count; //files count (actually files and folders count)

FilesCount can be updated when you call TFileListBox::Update method or change TFileListBox::Directory value. If flb connected to TDirectoryListBox object you can do it in TDirectoryListBox::OnChange event.

Leite33
September 19th, 2006, 03:39 PM
ok thanks. i have done it its easy. But how i can post the result in statusbar with text. For example 12 folders when the directorylistbox change

ncode
September 20th, 2006, 03:13 AM
I don`t understand clearly what the problem...
Try something like this:

TStatusBar* StatusBar;
TFileListBox* FileListBox;
TDirectoryListBox* DirectoryListBox;
<...>
void __fastcall TForm1::OnDirectoryListBoxChange(System::TObjectTObject* Sender)
{
StatusBar->SimpleText = IntToStr(FileListBox->Items->Count) + " files."
}

P.S. I didn`t compile this code...

Leite33
September 20th, 2006, 06:10 AM
i will try it thanks.I think its good idea