bacon7181
asked on
Notify designer that property has changed type
I have two classes that use ExpandableObjectConverters to provide properties for controls that expose them as properties. Lets call these PropertyClassA and PropertyClassB. If I expose a property as a generic Object call it MyProperties() and return a PropertyClassA the Property grid of the designer will let me see the properties of PropertyClassA. If I have another property that changes the value that is returned by MyProperties() to a PropertyClassB how do I notify the designer that my property types of changed so that it can refresh its display?
That sounds like a mouthfull and I like examples. When I toggle the 'TypeA' property of MyCustomControl below the property grid does not reflect the change. And yes this is a very convoluted example ;-)
<TypeConverter(GetType(Exp andableObj ectConvert er))> _
public class PropertyClassA
public property Name as string ...
public property ClassAValue as string ...
end class
<TypeConverter(GetType(Exp andableObj ectConvert er))> _
public class PropertyClassB
public property Name as string ...
public property ClassBValue as integer ...
end class
public class MyCustomControl
inherits UserControl
private myProperties as Object = new PropertyClassA
public writeonly property TypeA as Boolean
Set(value as boolean)
if value then
myProperties = new PropertyClassA
else
myProperties = new PropertyClassB
end if
End If
End property
public property MultiTypeProperties as Object ...
end class
That sounds like a mouthfull and I like examples. When I toggle the 'TypeA' property of MyCustomControl below the property grid does not reflect the change. And yes this is a very convoluted example ;-)
<TypeConverter(GetType(Exp
public class PropertyClassA
public property Name as string ...
public property ClassAValue as string ...
end class
<TypeConverter(GetType(Exp
public class PropertyClassB
public property Name as string ...
public property ClassBValue as integer ...
end class
public class MyCustomControl
inherits UserControl
private myProperties as Object = new PropertyClassA
public writeonly property TypeA as Boolean
Set(value as boolean)
if value then
myProperties = new PropertyClassA
else
myProperties = new PropertyClassB
end if
End If
End property
public property MultiTypeProperties as Object ...
end class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.