Mohit Vashistha
Mohit Vashistha

Reputation: 1904

Open file filter dialog without showing file filter

We can set the filter text for the file open dialog using pipe sepration:

fDialog.Filter =
           "NCF files (*.ncf)|*.ncf|All files (*.*)|*.*|No Extensions (*.)|*.";

But when I create a list of all supported file type the filter dropdown becomes way too long:

Open file dialog with long filter

File filter string is

All Supported Formats| *.000;*.2dm;*.ace2;*.adf;*.asc;*.avi;*.bag;*.bil;*.bin;*.blx;*.bmp;*.bsq;*.bt;*.catd;*.csv;*.dat;*.ddf;*.dem;*.dgn;*.dgrda;*.dlg;*.doq;*.doqq;*.drg;*.dt0;*.dt1;*.dt2;*.dwg;*.dxf;*.e00;*.ecw;*.elevgrid;*.enz;*.enzd;*.ers;*.fgb;*.flt;*.gdb;*.gdbtable;*.gen;*.gff;*.gif;*.gml;*.gmt;*.gpkg;*.gpx;*.grc;*.grd;*.gtx;*.gxf;*.hdf;*.hdr;*.hf2;*.hgt;*.img;*.ingr;*.isg;*.j2k;*.jml;*.jp2;*.jpeg;*.jpf;*.jpg;*.jpx;*.json;*.kml;*.kmz;*.kro;*.landuse;*.las;*.laz;*.lcp;*.map;*.mbtiles;*.mdb;*.mem;*.mif;*.mrf;*.n1;*.nat;*.nez;*.nezd;*.ntf;*.ods;*.pcx;*.pdf;*.penz;*.penzd;*.pix;*.pnez;*.pnezd;*.png;*.pnt;*.ppi;*.prf;*.pts;*.rda;*.rec;*.rgb;*.rik;*.rst;*.rsw;*.shp;*.sid;*.sigdem;*.skp;*.sql;*.sqlite;*.svg;*.sxf;*.tab;*.ter;*.tga;*.thf;*.tif;*.tif*;*.tiff;*.toc;*.txt;*.vct;*.vfk;*.view;*.vrt;*.wmv;*.xls;*.xml;*.xpm;*.xyz;.landxml
| 3D Model Formats (*.kml; *.kmz)| *.kml; *.kmz
| AutoCAD RealDWG™ Formats (*.dwg; *.dxf)| *.dwg; *.dxf
| GeoTIFF Georeferenced Raster Formats (*.tif; *.tiff)| *.tif; *.tiff
| Grid Elevation Formats (*.adf; *.asc; *.bil; *.bsq; *.bt; *.catd; *.ddf; *.dem; *.e00; *.elevgrid; *.flt; *.grd; *.img; *.ingr; *.jp2; *.tif; *.tiff)| *.adf; *.asc; *.bil; *.bsq; *.bt; *.catd; *.ddf; *.dem; *.e00; *.elevgrid; *.flt; *.grd; *.img; *.ingr; *.jp2; *.tif; *.tiff
| Land Cover Grid Format (*.hdf)| *.hdf
| LandXML Formats (*.landxml; *.xml)| *.landxml; *.xml
| Point Formats (*.asc; *.csv; *.enz; *.enzd; *.nez; *.nezd; *.penz; *.penzd; *.pnez; *.pnezd; *.pnt; *.pts; *.txt; *.xyz)| *.asc; *.csv; *.enz; *.enzd; *.nez; *.nezd; *.penz; *.penzd; *.pnez; *.pnezd; *.pnt; *.pts; *.txt; *.xyz
| Raster Image Formats (*.bil; *.bmp; *.doq; *.doqq; *.drg; *.e00; *.ecw; *.ers; *.gif; *.img; *.j2k; *.jp2; *.jpeg; *.jpg; *.pcx; *.png; *.sid; *.tif; *.tiff)| *.bil; *.bmp; *.doq; *.doqq; *.drg; *.e00; *.ecw; *.ers; *.gif; *.img; *.j2k; *.jp2; *.jpeg; *.jpg; *.pcx; *.png; *.sid; *.tif; *.tiff
| Spatial Database Formats (*.gdb; *.gdbtable; *.mdb; *.mif; *.sqlite; *.tab)| *.gdb; *.gdbtable; *.mdb; *.mif; *.sqlite; *.tab
| Vector Formats (*.dlg; *.e00; *.gml; *.kml; *.kmz; *.shp; *.skp; *.xml; *.xyz;)| *.dlg; *.e00; *.gml; *.kml; *.kmz; *.shp; *.skp; *.xml; *.xyz;
| All Files (*.*)| *.*

We need to show only the "All Supported Files" and do not need to list all the files extension show that the combobox is not that long and easy to read. Some software already does that:

Short file filter dialog

How can we set the open file filter so that it doesn't show file extension.

Upvotes: 0

Views: 446

Answers (1)

Ankur Gupta
Ankur Gupta

Reputation: 537

You just need to add (*.*) before the pipe separation | and after that, you can mention the file extensions you want to support. They won't be displayed in the dialog filter.

The solution for the mentioned issue is:

All Supported Formats (*.*) |*.000;*.2dm;*.ace2;*.adf;*.asc;*.avi;*.bag;*.bil;*.bin;*.blx;*.bmp;*.bsq;*.bt;*.catd;*.csv;*.dat;*.ddf;*.dem;*.dgn;*.dgrda;*.dlg;*.doq;*.doqq;*.drg;*.dt0;*.dt1;*.dt2;*.dwg;*.dxf;*.e00;*.ecw;*.elevgrid;*.enz;*.enzd;*.ers;*.fgb;*.flt;*.gdb;*.gdbtable;*.gen;*.gff;*.gif;*.gml;*.gmt;*.gpkg;*.gpx;*.grc;*.grd;*.gtx;*.gxf;*.hdf;*.hdr;*.hf2;*.hgt;*.img;*.ingr;*.isg;*.j2k;*.jml;*.jp2;*.jpeg;*.jpf;*.jpg;*.jpx;*.json;*.kml;*.kmz;*.kro;*.landuse;*.las;*.laz;*.lcp;*.map;*.mbtiles;*.mdb;*.mem;*.mif;*.mrf;*.n1;*.nat;*.nez;*.nezd;*.ntf;*.ods;*.pcx;*.pdf;*.penz;*.penzd;*.pix;*.pnez;*.pnezd;*.png;*.pnt;*.ppi;*.prf;*.pts;*.rda;*.rec;*.rgb;*.rik;*.rst;*.rsw;*.shp;*.sid;*.sigdem;*.skp;*.sql;*.sqlite;*.svg;*.sxf;*.tab;*.ter;*.tga;*.thf;*.tif;*.tif*;*.tiff;*.toc;*.txt;*.vct;*.vfk;*.view;*.vrt;*.wmv;*.xls;*.xml;*.xpm;*.xyz;.landxml

Upvotes: 1

Related Questions