WinForm file Filter

Source: Internet
Author: User

In the. NET Framework, Microsoft has encapsulated a dialog box--openfiledialog for opening a file. The dialog box contains a property--filter that can filter the file, which, with this property, can optionally filter out the files we need.

?? Therefore, it is necessary to remember the format of the Filter property. The format is divided into two situations:

1 // A filter item contains multiple formats 2 " image file (*.gif;*.png;*.jpg;*.bmp;*.ico) |*.gif;*.png;*.jpg;*.bmp;*.ico " ; 3 // Multiple filter Items 4 ofd. Filter =  "PDF file (*.pdf) |*.pdf| text file (*.txt) |*.txt";

Example : If the Filter property is set as follows:

1Ofd. Filter ="All Files (*. *) |*.*"+"|"+2     "text file (*.txt) |*.txt"+"|"+3     "PDF file (*.pdf) |*.pdf"+"|"+4     "Office Documents (*.DOC;*.DOCX;*.XLS;*.XLSX;*.PPT;*.PPTX) |*.doc;*.docx;*.xls;*.xlsx;*.ppt;*.pptx"+"|"+5     "image file (*.gif;*.png;*.jpg;*.jpeg;*.bmp;*.ico) |*.gif;*.png;*.jpg;*.jpeg;*.bmp;*.ico"+"|"+6     "audio files (*.mp3;*.mid;*.wav;) |*.mp3;*.mid;*.wav;"+"|"+7     "video file (*.mp4;*.avi;*.rmvb;*.wmv;*.mkv;*.flv) |*.mp4;*.avi;*.rmvb;*.wmv;*.mkv;*.flv"+"|"+8     "compressed Files (*.rar;*.zip;*.7z) |*.rar;*.zip;*.7z"+"|"+9     "HTML file (*.htm;*.html) |*.htm;*.html"+"|"+Ten     "XML file (*.xml;*.xaml) |*.xml;*.xaml"+"|"+ One     "code file (*.c;*.cpp;*.h;*.hpp;*.cs;*.java) |*.c;*.cpp;*.h;*.hpp;*.cs;*.java"+"|"+ A     "Program Files (*.exe;*.dll;*.jar;*.class) |*.exe;*.dll;*.jar;*.class";

Article Sync update: http://www.motyer.cn/Files/BlogDetails/winform-file-filter.html

WinForm file Filter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.