Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CheckListBox 1

Status
Not open for further replies.

Galpus

Technical User
Apr 11, 2002
3
GB
Hi, I have DriveComboBox, DirectoryListBox and a FileListBox on a form. The FileListBox is hidden and the files displayed in a CheckListBox instead using -

CheckListBox.Items:=FilesListBox.Items;

This works great i.e. the files are displayed for easy selection in the CheckListBox. However, I'm finding it hard to select (check) a file and capture it's complete file path.


Any ideas ?


Thanks...
 
I am not sure why you have a problem.

DirectoryListBox1.Directory is the property that contains the directory name (including the drive letter).

Your CheckListBox can contain zero or more checked file names. You need to prefix the checked file name with DirectoryListBox1.Directory.

So suppose you want the complete file path of the first file checked in your CheckListBox displayed in Edit1.Text when you click on Button1. Then your code should look something like:
Code:
procedure TForm1.Button1Click(Sender: TObject);
var
 x: integer;
begin
 Edit1.Text := '';
 for x := 0 to CheckListBox1.Count - 1 do
  if CheckListBox1.Checked[x] then begin
   Edit1.Text := DirectoryListBox1.Directory + '\' + CheckListBox1.Items[x];
   break;
  end;
end;

Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top