2

enter image description here

I want to have some properties like this for example I want to have System Permission and it contains properties like SMS,Line, and ...

  • There are properties for each control. While it is a good idea to be able to do this, I don't think you can group selected properties in a new defined tab. – NoChance Apr 11 '21 at 06:23
  • 2
    Look for [ExpandableObjectConverter](https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.expandableobjectconverter), related: https://stackoverflow.com/questions/18546919/how-to-display-object-with-sub-class-in-propertygrid/49145207 – Klaus Gütter Apr 11 '21 at 06:27
  • See the [Font object](https://referencesource.microsoft.com/#System.Drawing/commonui/System/Drawing/Advanced/Font.cs,33) in the .Net Source code. That's a complex object. To show its properties in the PropertyGrid, it requires a TypeConverter and a custom Editor. If your Class Object contains properties that already define a TypeConverter (as Font, or e.g., Size, Point, Rectangle), you don't need to do anything, these are already setup in the Framework. Just decorate the class Object used as the Property value with `[Serializable]` and `[TypeConverter(typeof(ExpandableObjectConverter))]`. – Jimi Apr 11 '21 at 07:19
  • If your Class Object instead defines complex objects that are not already known and *understood* by the Framework, you need to provide your own TypeConverter(s) and, possibly, a custom Editor (which actually boils down to a simple Form that provides means to edit the properties of a *complex object*. e.g., The Font selector that is opened when you want to change or configure a `Font` Type property). – Jimi Apr 11 '21 at 07:21
  • @AlexanderPetrov this is for category, I need something that make node for me – Ali Sharafzade Apr 11 '21 at 08:07

1 Answers1

0

The UI here is based on the TypeDescriptor view of the object being inspected. Grouping isn't a concept, but it does support sub-objects. The easiest way to do what you want is to simply model the group's as different types, so: have a class that represents System Permission things, with properties for SMS etc. Attributes like [DisplayName(...)] can be used to tweak display with spaces etc. You'd then have an instance of your type as a property on the object being edited.

Everything here can be done without changing the model, but that requires custom type descriptors, which is hard to do and not particularly exciting. Changing the object model is qucker and easier.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900