The blog has moved to a new address. The blog is now located at

Sunday, February 04, 2007

Propertygrid: How to show only specific file extensions?


Use Editor Attribute


"Resume File Name")]
typeof(DocFileEditor), typeof(UITypeEditor))]
public string ResumeFile
return _ResumeFile;
= value;



Override InitializeDialog method and provide Filter string that describes allowed file extensions

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace WindowsApplication1
class DocFileEditor : FileNameEditor
///Initializes the open file dialog when it is created.
///<param name="openFileDialog">The <see cref="T:System.Windows.Forms.OpenFileDialog">
</see> to use to select a file name. </param>
protected override void InitializeDialog(OpenFileDialog openFileDialog)
= false;
= "Doc files (*.doc)|*.doc|All files (*.*)|*.*";