(C#)OpenFileDialog Filter not working for me

G

gs_sarge

Hello:

I'm trying to get my OpenFileDialog box to filter out all files except
jpg files, but am unable to do so.

When I run the dialog box (Called from another custom dialog box) and
click on the 'Files of Type' field, it won't drop down.

I've even tried using the string given in the MSDN help files; that
won't work either.

I'm running on 1.1 using Visual Studio .NET 2003.

Is there another field or property I need to set. Here are the
settings below that are listed in the constructor of the parent form:


//
// pictureGetFileDialog
//
this.pictureGetFileDialog.DefaultExt = "jpg";
this.pictureGetFileDialog.Filter = "jpg files (*.jpg)|*.jpg";
this.pictureGetFileDialog.FilterIndex = 0;
this.pictureGetFileDialog.Title = "Select a picture to add to this
user\'s collection";

(the title is being truncated by the newsgroup software. actual title
is on one line)


Here is how it's being called:

string name = Char.ToUpper(this.member.MemberDetails.FirstName[0]) +
this.member.MemberDetails.FirstName.Substring(1) + " " +
Char.ToUpper(this.member.MemberDetails.LastName[0]) +
this.member.MemberDetails.LastName.Substring(1);

this.pictureGetFileDialog = new OpenFileDialog();

/// set open title
///
this.pictureGetFileDialog.Title = String.Format
("Select an image for {0}",name);


try
{

dlgResult = this.pictureGetFileDialog.ShowDialog(this);

....


I've looked on the web, but found no instances of problems like this.

I'm calling this from a thread other than the UI thread. However,
since it is a dialog box (no BeginEnvoke found), I don't see this as a
problem.

Any help provided here would be greatly appreciated.

Thanks

Steve
 
G

gs_sarge

Hi:

I figureed out my problem:

When calling the openFileDialog, I was reinstantiating it as a new
object
this.pictureGetFileDialog = new OpenFileDialog();
basically overwriting all of my filter information.

Oh well. I guess I'm the .NET bug in this case! :)


Hello:

I'm trying to get my OpenFileDialog box to filter out all files except
jpg files, but am unable to do so.

When I run the dialog box (Called from another custom dialog box) and
click on the 'Files of Type' field, it won't drop down.

I've even tried using the string given in the MSDN help files; that
won't work either.

I'm running on 1.1 using Visual Studio .NET 2003.

Is there another field or property I need to set. Here are the
settings below that are listed in the constructor of the parent form:


//
// pictureGetFileDialog
//
this.pictureGetFileDialog.DefaultExt = "jpg";
this.pictureGetFileDialog.Filter = "jpg files (*.jpg)|*.jpg";
this.pictureGetFileDialog.FilterIndex = 0;
this.pictureGetFileDialog.Title = "Select a picture to add to this
user\'s collection";

(the title is being truncated by the newsgroup software. actual title
is on one line)


Here is how it's being called:

string name = Char.ToUpper(this.member.MemberDetails.FirstName[0]) +
this.member.MemberDetails.FirstName.Substring(1) + " " +
Char.ToUpper(this.member.MemberDetails.LastName[0]) +
this.member.MemberDetails.LastName.Substring(1);

Damn you, sly little fox!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top