How can I get a PropertyGrid to show a SaveFileDialog?
c#, winforms
Solution
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.
Problem
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. Is there an existing class that I can specify in the System.ComponentModel.Editor attribute so that a SaveFileDialog is displayed?