DirListBoxUpdate (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following sample code sets the directory of DirectoryListBox1 to c:\\WINDOWS when the form is created. When Button1 is pressed, a subdirectory called c:\\WINDOWS\\mytemp is added, but note that it is not updated in DirectoryListBox1 until Button2 is pressed and Update is called. Note: A EInOutError occurs if you add a directory that already exists. You must also add the new directory to your current directory. Capitalization matters in C++ and the file separators must be "\\".

Code

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  ForceDirectories(Edit1->Text);
}

void __fastcall TForm1::Button2Click(TObject *Sender)
{
  DirectoryListBox1->Update();
}

__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
  DirectoryListBox1->Directory = "c:\\WINDOWS";
}

Uses

Personal tools
Assistance