问题描述
我有,我希望能够以显示SaveFileDialog为用户在数据导出到一个新文件的过程属性网格控制。我可以很容易地挂钩一个OpenFileDialog与FileNameEditor但似乎没有要保存文件的等价类。
I have a property grid control where I want to be able to display a SaveFileDialog as the user is in the process of exporting data to a new file. I can easily hook up an OpenFileDialog with a FileNameEditor but there doesn't seem to be an equivalent class for saving files.
有没有办法,我可以指定一个现有的类在System.ComponentModel.Editor属性,这样一个SaveFileDialog显示?
Is there an existing class that I can specify in the System.ComponentModel.Editor attribute so that a SaveFileDialog is displayed?
推荐答案
所以您在设置的对象 propertyGrid1.SelectedObject
需要的公共属性如下所示:
So the object that you set in the propertyGrid1.SelectedObject
needs a public property like the following:
private string _saveFile;
[BrowsableAttribute(true)]
[EditorAttribute(typeof(SaveFileNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
public string SaveFileEditorVlad
{
get { return _saveFile; }
set { _saveFile = value; }
}
为了使的的回答工作:)然后在运行时,当您编辑此属性,省略号会显示,你就可以选择一个文件另存为。
in order to make Stewy's answer work :) Then at runtime, when you edit the this property, the ellipsis will show and you'll be able to select a file to Save As.
这篇关于我怎样才能得到一个PropertyGrid中显示SaveFileDialog?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!