Microsoft Communities

Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I change the "(Collection)" string in a UITypeEditor for a collection?

The string "(Collection)" is coming from the TypeConverter on that property, which is CollectionConverter. You can modify the string as shown here:

[ TypeConverter( typeof( CustomCollectionConverter ) ] 
public class CustomCollection : SomeBaseCollection 
{ 
  // ... 
}
 
internal class CustomCollectionConverter : CollectionConverter 
{ 
  public override object ConvertTo( ITypeDescriptorContext context, 
    CultureInfo culture, object value, Type destinationType ) 
  { 
    if ( destinationType == typeof( string ) && value is ICollection ) 
      return "Custom collection"; // any text you like 
    return base.ConvertTo(context, culture, value, destinationType); 
  } 
}

Shawn Burke, Microsoft



Page view counter