We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Custome Property Editor

Hi, is it possible to show the node properties in the property edit window.i have two collection as shown in the code, both are IList. Is it possible to show them in the property window.

public class Node : Symbol
{

private IList NodeParameterCollection; ///1
private IList Collection=null; ///2
}

Thank you.
Regards,

1 Reply

J. J.Nagarajan Syncfusion Team March 15, 2007 06:15 PM UTC

Hi Ali,

Yes you can show the node's properties that you wish to expose to in property grid. You can use PropertyDescriptorCollection class to achieve this. Please refer to the following code snippet

public class MySymbolConverter : System.ComponentModel.TypeConverter
{
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
return base.ConvertTo(context, culture, value, destinationType);
}

public override bool GetPropertiesSupported(ITypeDescriptorContext context)
{
return true;
}

public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
{
System.Attribute[] attrs = new System.Attribute[]
{
new System.ComponentModel.BrowsableAttribute(true)
};

PropertyDescriptor[] props = new PropertyDescriptor[4];
props[0] = TypeDescriptor.CreateProperty(typeof(MySymbol), "Name", typeof(string), attrs);
props[1] = TypeDescriptor.CreateProperty(typeof(MySymbol), "ClickCount", typeof(int), attrs);
props[2] = TypeDescriptor.CreateProperty(typeof(MySymbol), "Labels", typeof(LabelCollection), attrs);
props[3] = TypeDescriptor.CreateProperty(typeof(MySymbol), "DefaultLabelName", typeof(string), attrs);
return new PropertyDescriptorCollection(props);

// This code returns all browsable properties
return TypeDescriptor.GetProperties(value, attrs);

}
}

Also refer to our Custom Symbol sample( \\Windows\Diagram.Windows\Samples\Symbol Design\CustomSymbol) that demonstrates this completely.

Let me know if you have any questions.

Regards,
Nagaraj

Loader.
Live Chat Icon For mobile
Up arrow icon