propertygrid

ICustomTypeDescriptor, TypeDescriptionProvider, TypeConverter, and UITypeEditor

假装没事ソ 提交于 2019-11-28 15:48:16
I'm trying to get an overall understanding of how you use ICustomTypeDescriptor, TypeDescriptionProvider, TypeConverter, and UITypeEditor to change how a PropertyGrid displays and interfaces with an object. Can someone tell me if this is right, or if I missed any major concepts or points? I'm really just trying to understand why and when you would use each class. ICustomTypeDescriptor Implementing this interface in a class totaly overrides the native properties of a class and replaces them with the PropertyDescriptors returned by ICustomTypeDescriptor.GetProperties() TypeDescriptionProvider

Programmatically Hide Field in PropertyGrid

心已入冬 提交于 2019-11-28 11:42:20
Using <System.ComponentModel.TypeConverter(GetType(System.ComponentModel.ExpandableObjectConverter))> _ on the declaration of a class (which is a property of another class) that consists of a number properties. I load an instance of this class with simply ... PropertyGrid1.SelectedObject = oColumn Obviously I don't want to manually build the propertygrid in code, I know how to do that. But here's the problem. Depending on the value of a property, certain other properties should not be visible, as though I'd used the <System.ComponentModel.Browsable(False)> _ attribute on the property

Expand C# propertygrid on show

此生再无相见时 提交于 2019-11-28 11:33:31
i have a question about property grid. when the form is shown i would like a group to be expand rather then collapsed. i have search a lot for that on the web and could not find it yet. any thoughts. If you want to expand all items in the grid it is fairly simple. The property grid has a method for doing that: propertyGrid.ExpandAllGridItems(); If it is a certain group you want to expand you can use this method: private static void ExpandGroup(PropertyGrid propertyGrid, string groupName) { GridItem root = propertyGrid.SelectedGridItem; //Get the parent while (root.Parent != null) root = root

Hide some properties in PropertyGrid at run-time

耗尽温柔 提交于 2019-11-28 08:25:25
问题 I am doing a project that allows user to customized the properties of a Control . I have a form that has a control like Label , TextBox , Button and PropertyGrid control. When the user clicks on the Label i am showing the properties of the Label in the ProeprtyGrid which is all working fine using below code: propertyGrid1.SelectedObject = SelectedControl; But I just want to show some properties like BackColor , Font , ForeColor , Text . Is it possible to hide the properties since I don't want

Modifying structure property in a PropertyGrid

半世苍凉 提交于 2019-11-28 08:02:27
问题 Why SomeClass.ClassField.StructField property doesn't change in a propertyGrid ? It seems, propertyGrid doesn't call SomeClass.ClassField.set after SomeStruct instance has been changed. But same code works well with Point instead of SomeStruct . [TypeConverter(typeof(ExpandableObjectConverter))] public struct SomeStruct { private int structField; public int StructField { get { return structField; } set { structField = value; } } public override string ToString() { return "StructField: " +

Show detailed Folder Browser from a PropertyGrid

对着背影说爱祢 提交于 2019-11-28 05:59:18
Please note it is not a duplicate question. How to show a detailed FolderBrowser as in the image below from a PropertyGrid (from the field/property which has ellipses ...) Using [EditorAttribute(typeof(System.Windows.Forms.Design.FileNameEditor), typeof(System.Drawing.Design.UITypeEditor))] [EditorAttribute(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))] We get the minimalistic folder browser Here is a custom UITypeEditor that allows you to use the Vista Folder Browser: You can use it like any other editor: [EditorAttribute(typeof

Can we change the text/background color of an individual property in PropertyGrid

我只是一个虾纸丫 提交于 2019-11-28 05:15:31
问题 I have a .NET PropertyGrid control which displays properties of some class. I want to change the color or font or background color(it doesn't matter just that they look different from the other displayed properties) of some property. I can do with writing custom editor but I was wondering: If an easier method exists? If I use custom editor then how do i change the editor of built-in types like bool, int etc? 回答1: No can do. The class that determines how an item is drawn is PropertyGridView.

Updating a PropertyGrid

邮差的信 提交于 2019-11-28 03:25:59
问题 How can I have a property grid update automatically when the object in its SelectedObject property changes? I've tried implementing INotifyPropertyChanged in my class but the property grid does not actually show the new propertyies of the object in the background until I click on it. I've tried subscribing to the PropertyChanged event of my object directly, and calling the Refresh() method of the PropertyGrid when it is envoked. But some of my properties are related. Meaning changing one

What's the correct way to edit a collection in a property grid

与世无争的帅哥 提交于 2019-11-28 02:05:55
问题 I have a class which is displayed in a property grid. One of the properties is a List<SomeType> . What's the easiest/correct way to set up the code so that I can add and remove items from this collection through the property grid, preferably using the standard CollectionEditor . One of the wrong ways is like this: set not being called when editing a collection User annakata suggest that I expose an IEnumerable interface instead of a collection. Can someone please provide me with more details?

Properties generated at runtime (PropertyGrid.SelectedObject)

旧街凉风 提交于 2019-11-28 01:41:13
问题 Ok, this is a tough one. Introduction: My idea is to attach an instanciated QueryBuilder class which I wrote, to a PropertyGrid. The QueryBuilder class now contains a couple of fields, which are hardcoded like in the example below. Thus allowing a user to specify, which fields should be used in a query in what way (sorted, grouped, and so on). After the user having specified all the settings to these properties (by code or via the PropertyGrid GUI), the QueryBuilder is able to produce a query