I tried using class as a property but I can't change it's sub properties in the "Properties Tab"
I want to make a property like the Font
property
in this picture
It is used to maintain a list of values in which the key is a string and the value is also a string i.e; it can be used to store and retrieve string type data from the properties file.
Property in C# is a member of a class that provides a flexible mechanism for classes to expose private fields. Internally, C# properties are special methods called accessors.
Properties are attributes or features that characterize classes. While classes are groups of objects, an instance is a specific object that actually belongs to a class.
Within class methods non-static properties may be accessed by using -> (Object Operator): $this->property (where property is the name of the property). Static properties are accessed by using the :: (Double Colon): self::$property .
You need to decorate it with [TypeConverter(typeof(ExpandableObjectConverter))]
to get the sub-properties to show up in the editor.
public struct MyStruct
{
public int One;
public int Two;
public int Three;
}
public class MyEditableClass : Control
{
[TypeConverter(typeof(ExpandableObjectConverter))]
public MyStruct MyProperty { get; set; } = new MyStruct();
}
The properties will now be expandable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With