Home How can I avoid showing extensions on one Filter option in OpenFileDialog?
Reply: 1

How can I avoid showing extensions on one Filter option in OpenFileDialog?

SSteve
1#
SSteve Published in 2017-11-15 00:18:56Z

In addition to a list of supported file formats, I want to have a catch-all of "All Supported Files". I want the extensions to be displayed for the individual formats, but not for the catch-all. I thought this would do it:

    const string OpenFileFilters = "AAA Files (*.aaa)|*.aaa|" +
                           "BBB Files (*.bbb)|*.bbb|" +
                           "CCC Files (*.ccc)|*.ccc|" +
                           "DDD Files (*.ddd)|*.ddd|" +
                           "EEE Files (*.eee)|*.eee|" +
                           "FFF Files (*.fff)|*.fff|" +
                           "GGG Files (*.ggg)|*.ggg|" +
                           "HHH Files (*.hhh)|*.hhh|" +
                           "III Files (*.iii)|*.iii|" +
                           "All Supported Files |*.aaa;*.bbb;*.ccc;*.ddd;*.eee;*.fff;*.ggg;*.hhh;*.iii";

    var dialog = new OpenFileDialog
    {
        InitialDirectory = FileUtilites.ValidateInitialDirectory(initialDirectory),
        Filter = OpenFileFilters,
        FilterIndex = Settings.Default.OpenFileFilter,
        Multiselect = true
    };

    var result = dialog.ShowDialog();

But it gives me this:

Is there some way to specify the Filter string so that it will not include the long list of extensions on that last option?

SSteve
2#
SSteve Reply to 2017-11-16 01:16:14Z

I ended up using

const string OpenFileFilters = "AAA Files (*.aaa)|*.aaa|" +
                       "BBB Files (*.bbb)|*.bbb|" +
                       "CCC Files (*.ccc)|*.ccc|" +
                       "DDD Files (*.ddd)|*.ddd|" +
                       "EEE Files (*.eee)|*.eee|" +
                       "FFF Files (*.fff)|*.fff|" +
                       "GGG Files (*.ggg)|*.ggg|" +
                       "HHH Files (*.hhh)|*.hhh|" +
                       "III Files (*.iii)|*.iii|" +
                       "All Supported Files (*.*)|*.aaa;*.bbb;*.ccc;*.ddd;*.eee;*.fff;*.ggg;*.hhh;*.iii";

It shows (*.*) in the combo box, which is a lie, but it's a white lie.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.305069 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO