Jerry Jerry - 15 days ago 7
C# Question

How do I remove the elipsis for a custom UITypeEditor that is read-only?

I have two fields that are of the same type in my property-grid. However, one is read-only, the other is editable.

Both of these fields are of a custom type, and thus have a custom UITypeEditor, which puts the elipsis ([...]) button on the field.

[
CategoryAttribute("5 - Wind"),
DisplayName("Factored Area"),
Description("The factored area for the segment."),
EditorAttribute(typeof(umConversionTypeEditor), typeof(UITypeEditor)),
TypeConverter(typeof(umConversionTypeConverter)),
ReadOnly(true)
]
public FactoredAreaClass FactoredArea { ... }

[
CategoryAttribute("5 - Wind"),
DisplayName("Factored Area Modifier"),
Description("The factored area modifier."),
EditorAttribute(typeof(umConversionTypeEditor), typeof(UITypeEditor)),
TypeConverter(typeof(umConversionTypeConverter))
]
public FactoredAreaClass FactoredAreaMod { ... }


In this example, FactoredAreaMod is available to be edited, but BOTH have the elipsis, which will cause great confusion with the users. Any way to turn that off??

Answer

Use the ReadOnly attribute. This marks it as design-time read-only while keeping it read/write for runtime use.

Also, you should either apply the Editor attribute to the type rather than the properties. There's no gain in applying it to a property if you don't want that property to be editable.