DirListBoxDrive (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following example assumes that a drive combo box, a file list box, and a directory list box are on a form. Add this code as the OnChange event handler for the drive combo box and the OnChange event handler for the directory list box. When the user changes the drive using the combo box, the directory list box and file list box will update to reflect the new drive and the current directory on that drive. When the user double-clicks a directory in the file list box, it will update to reflect the new directory.

Code

procedure TForm1.DirectoryListBox1Change(Sender: TObject);
begin
  FileListBox1.Directory := DirectoryListBox1.Directory;
end;

procedure TForm1.DriveComboBox1Change(Sender: TObject);
begin
  DirectoryListBox1.Drive := DriveComboBox1.Drive;
  FileListBox1.Drive := DriveComboBox1.Drive;
  FileListBox1.Directory := DirectoryListBox1.Directory;
end;

Uses