Show detailed Folder Browser from a PropertyGrid

Here is a custom UITypeEditor that allows you to use the Vista Folder Browser: You can use it like any other editor: [EditorAttribute(typeof(FolderNameEditor2), typeof(System.Drawing.Design.UITypeEditor))] It relies on a custom FolderBrowser2 class that I have written for the occasion. Of course, this will work only on Windows Vista and higher. On previous Windows version, there is … Read more

Hide some properties in PropertyGrid at run-time

I believe you are looking for custom type descriptors. While the other answer is sharing correct information about Browsable attribute and BrowsableAttributes of PropertyGrid, but I’d say it’s not a proper practical solution for the problem. It’s not practical to set Browsable attribute, or any other custom attributes for existing control classes like Label, Button, … Read more

PropertyGrid Browsable not found for entity framework created property, how to find it?

Using ICustomTypeDescriptor is definitely the good solution when you want dynamic (set at runtime) properties. Here is generic ICustomTypeDescriptor utility class that I’ve been using for this sort of property grid hacking, it’s pretty straightforward to use: public sealed class DynamicTypeDescriptor: ICustomTypeDescriptor, INotifyPropertyChanged { private Type _type; private AttributeCollection _attributes; private TypeConverter _typeConverter; private Dictionary<Type, … Read more

Remove C# attribute of a property dynamically

You can not remove the attribute at runtime, but you can use reflection to change the ReadOnly attribute’s ReadOnly private backing field to False. Making it the equivalent of [ReadOnly(false)] See this article for details: http://codinglight.blogspot.com/2008/10/changing-attribute-parameters-at.html Edit: fixed link

How to add property-level Attribute to the TypeDescriptor at runtime?

Unlike others have suggested, it’s quite possible, and also not that hard. For example, you want to add some new attributes to some properties, which you can select at runtime based on some criteria. There’re two helper classes we’ll need to implement this. First goes PropertyOverridingTypeDescriptor, it allows us to supply our own property descriptors … Read more

How to create custom PropertyGrid editor item which opens a form?

You need to implement a modal UITypeEditor, using the IWindowsFormsEditorService service to display it: using System.ComponentModel; using System.Drawing.Design; using System.Windows.Forms; using System.Windows.Forms.Design; using System; class MyType { private Foo foo = new Foo(); public Foo Foo { get { return foo; } } } [Editor(typeof(FooEditor), typeof(UITypeEditor))] [TypeConverter(typeof(ExpandableObjectConverter))] class Foo { private string bar; public string … Read more