Mega Code Archive

 
Categories / Delphi / VCL
 

Refreshing the tdrivecombobox drive list

Question: How can I get the TDriveComboBox component to refresh its' list, given that networked drives can be added, deleted, and remapped, and drives can be hot swapped by using plug and play devices? Answer: The following example demonstrates surfacing the protected BuildList() method of the TDriveComboBox component to regenerate the list of current disk drives. Example: type TNewDriveComboBox = class(TDriveComboBox) end; procedure TForm1.Button1Click(Sender: TObject); var Drive : char; begin Drive := DriveComboBox1.Drive; TNewDriveComboBox(DriveComboBox1).BuildList; DriveComboBox1.Drive := Drive; end;