Here, the RichTextBox Control is used as an example >>>
When processing the load event in the class corresponding to the form, you can set the filter attribute for openfiledialog:
Private void form1_load (Object sender, eventargs e) {openfiledialog1.filename = ""; openfiledialog1.initialdirectory = @ "E: \"; openfiledialog1.filter = "text file | *. TXT | RTF File | *. RTF | all files | *. * "; openfiledialog1.filterindex = 2; savefiledialog1.filename = convert. tostring (datetime. now. ticks); // set a default file name for the saved file: savefiledialog1.filter = "text file | *. TXT | RTF File | *. RTF | all files | *. * "; savefiledialog1.filterindex = 2 ;}
If you accidentally write the above line of code as follows:
Openfiledialog1.filter = "text file | *. TXT | RTF File | *. RTF | all files | *. * "; savefiledialog1.filter =" text file | *. TXT | RTF File | *. RTF | all files | *. *";
At first glance, there is no difference between the two lines of code and the above Code. TXT and *. the keyword "rtf" is followed by a space. Although only one space is added, the filter attribute will become
The normal running effect is:
When comparing the filter option boxes of the two images, you will find significant differences.