Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to implement a custom Toolbox tool in ArcGIS, and am trying to setup a custom GPParameter that will take a file type with a specific extension.

I know that DEFileType is available and will provide a file browser. How do you set a filter for specific file types using this object?

I suspect this needs to be done via IGxFilterInfo, but am unable to find any relevant documentation or examples, and am having a difficult time finding an example anywhere.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You will need to set the parameter's Domain property with the appropriate domain information.

In your case, you will use the GPFileDomain class. Through its IGPFileDomain interface, you can add acceptable file types via the IGPFileDomain.AddType method. This method takes a string representing the file extension without the preceding dot.

The file dialog will show your "myext" (an example) extension as "File (*.myext)" filter text. You cannot (easily at least) change the "File" part of the text but that is a minor problem I guess.

share|improve this answer
    
That worked. I'd like to figure out how to change the "File" part - but it may not be possible. –  Reed Copsey Oct 28 '10 at 21:50
    
After some investigation I believe it is not possible. And if it is, probably with effort not worth the hassle. –  Petr Krebs Oct 28 '10 at 22:33
    
If you look at the built-in tools which use DEFileType for any of their parameters, there is not a single one where the filter text is different from the standard "File (*.ext)" format... –  Petr Krebs Oct 28 '10 at 22:35
    
Thanks for the updates... I've come to the same conclusion, btw –  Reed Copsey Nov 1 '10 at 16:59

There's a way you can do it though. If you write a custom control for the parameter and bind it to the parameter with ControlCLSID, you can add a button to the control that opens an OpenFileDialog. Evaluate the parameter's domain and set the dialog's Filter property to what you need.

share|improve this answer
    
btw, @petr: How did you find out about all the built-in tools that use DEFileType? –  frid Nov 5 '10 at 8:44
    
@find: Basically, I instantiated all the tools in the appropriate COM component category and examined their parameters. –  Petr Krebs Nov 5 '10 at 10:22
    
Anyway, you probably should have made a comment to my post instead of making a new post.. –  Petr Krebs Nov 5 '10 at 10:24
    
Thanks petr. I see, sorry I'm new to this forum. –  frid Nov 8 '10 at 10:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.