DirListBoxUpdate (Delphi)

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 mytemp is added to C:\WINDOWS, but note that it is not updated in DirectoryListBox1 until Button2 is pressed and Update is called. Note: An EInOutError will occur if you add a directory that already exists. Also, you must add the new directory to your current path to get things started.

Code

procedure TForm1.Button1Click(Sender: TObject);
begin
  MkDir(Edit1.Text);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  DirectoryListBox1.Update;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  DirectoryListBox1.Directory := 'c:\WINDOWS';
end;

Uses