Gtk# Multiple File Filter

女生的网名这么多〃 提交于 2019-12-11 08:46:47

问题


I want to display only image files in GTK# File Chooser

        fc.SelectMultiple = true;
        FileFilter filter  = new FileFilter();
        filter.Name = "Image files";
        filter.AddPattern ("*.jpg;*.jpeg;*.png;*.tif;*.bmp;*.gif;*.tiff");
        fc.Filter = filter;

This does not work.The file chooser does not show any Files. Can someone suggest me a proper way to do this.


回答1:


As shown in the sample from the docs, the AddPattern method is meant for adding a single pattern at a time. In contrast to the WinForms implementation and similar implementations, it does not set all patterns at a time, instead it adds one additional pattern to whatever has been added before.

Therefore, try splitting up your command:

fc.SelectMultiple = true;
FileFilter filter  = new FileFilter();
filter.Name = "Image files";
filter.AddPattern("*.jpg");
filter.AddPattern("*.jpeg");
filter.AddPattern("*.png");
filter.AddPattern("*.tif");
filter.AddPattern("*.bmp");
filter.AddPattern("*.gif");
filter.AddPattern("*.tiff");
fc.Filter = filter;


来源:https://stackoverflow.com/questions/23495203/gtk-multiple-file-filter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!