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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OpenFileDialog control - multiselect 2

Status
Not open for further replies.

Katy44

Technical User
Dec 12, 2003
723
GB
I am using an OpenFileDialog, and want the users to ba able to select many files in one go. I think the Multiselect property is what I want, but I'm not sure if I understand it exactly. Does it allow, opening the explorer window once, the user to select many files by holding down the Ctrl key while they select the files? If that is the case then it's not working for me - holding down Ctrl doesn't allow multiple selections, the usual Windows 'lasoo' isn't available etc.
Have I got the completely wrong idea?
Thanks for any help.
 
Yes, it is the multiselect property that should do what you are looking for. Here's some example code that opens up a OpenFileDialog and allows a use to select multiple files, then adds them to a listbox named lstAdditionalFiles.

Code:
OpenFileDialog myDialog = new OpenFileDialog();
myDialog.RestoreDirectory = true;
myDialog.Multiselect = true;

if (myDialog.ShowDialog(this) == DialogResult.OK)
{
     foreach(string file in myDialog.FileNames)
     {
        // Fill in location selected
        this.lstAdditionalFiles.Items.Add(file); 
     }
}

If you set the multi-select property to true, it should allow you to pick multiple entries with the control key.

-Aaron
 
Thank you that's what I thought. Do you have any idea why it's not working?
I'll start a completely new, very small windows app to test it.
Thanks for your help.
 
That's weird - it works perfectly.
Well now I know it can work as I want, I will get it to work!
Thanks a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top