OpenDialog


OpenDialog is a component which enables you to select a file from any directory
or drive.

Example:

- Drop a Button and a Label.
- Drop OpenDialog from Dialogs page.
- At Button's OnClick event write:

 OpenDialog1.Title:= 'Test for OpenDialog box';
if
OpenDialog1.Execute then
  Label1.Caption:=
OpenDialog1.FileName
else
  Label1.Caption:= 'No file seleceted';

Execute is a method of TOpenDialog, it shows OpenDialog box and returns True if
user selects a file and it returns
False if user presses cancel.

FileName property holds full-qualified file name (File name with it's full path).

If you want to filter files such as displaying only documents files, bitmap files,
and other extensions you can select filters at design time or run time. At design
time you can click on
Filter property of OpenDialog1 then you can write any files
type you want. At run time you can write files types such as:

 OpenDialog1.Filter:=
 'All files (*.*)|*.*|Documents'+
 '|*.doc;*.txt|Pictures|*.bmp;*.jpg|';


When you run this example again; below list will be appeared on (Files of type)
combo box:

 All files (*.*)
Documents
Pictures

See also:

SaveDialog