Hello,
I have .Net project in that I had to make customization in the Property Grid window so is it possible to apply Custom Filters for propertyGrid and if this is possible then please let me know to achieve this.
Thanks in Advace
Hello,
I have .Net project in that I had to make customization in the Property Grid window so is it possible to apply Custom Filters for propertyGrid and if this is possible then please let me know to achieve this.
Thanks in Advace
I'm trying to set a custom filter for propertygird's FileNameEditor.
Code://property [DisplayName("File Path")] [Category("Video Settings")] [Description("The path to the file to be played.")] [System.ComponentModel.Editor(typeof(MovieFileNameEditor), typeof(UITypeEditor))] public string FilePath { get { return _FilePath; } set { _FilePath = value; } } //FileNameEditor override internal class MovieFileNameEditor : System.Windows.Forms.Design.FileNameEditor { protected override void InitializeDialog(OpenFileDialog openFileDialog) { base.InitializeDialog(openFileDialog); openFileDialog.Filter = "Movie Files (*.avi, *.mpeg, *.mpg)|*.avi;*.mpeg;*.mpg"; openFileDialog.Title = "Select Movie File"; } }
Suppose your SelectedObject is a TextBox, and you want to display in a PropertyGrid only the "Size" property of your TextBox. As the PropertyGrid control is, it is not possible.
you may continue passing to the PropertyGrid.BrowsableAttributes property a collection of attributes like "PropertyNameAttribute". But unfortunately, such attributes don't exist.
I propose another approach: using a wrapper object that contains the object you want to display in the PropertyGrid. This wrapper will be passed to the PropertyGrid, instead of the object itself. So, the PropertyGrid will not directly display the object's properties, but the wrapper's ones. In this case, you need to subclass the PropertyGrid with a new control that overrides the SelectedObject property. That's exactly what I did, while writing the FilteredPropertyGrid control. This control is inherited from PropertyGrid and works the same way. I just added these useful properties:
- BrowsableAttributes: overridden from PropertyGrid.
- HiddenAttributes: all the properties that have the attributes contained in the collection are hidden.
- BrowsableProperties: all the properties contained in the collection are displayed.
- HiddenProperties: all the properties contained in the collection are not displayed.
Bookmarks