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