conditional ReadOnly Property

Ste_Moore01

Member
Joined
Aug 12, 2013
Messages
6
Programming Experience
3-5
Hi,

I'm creating a UserControl where there are 2 properties, Resizable and ResizeType.

Resizable is a boolean and ResizeType is an integer.

I want ResizeType to be readonly if Resizable is False and writeable if it is True

Is this possible?
 
You can't change whether the property is ReadOnly or not while the program is running, that's a compile time declarative.
What you can do is in the Set part of the ResizeType property is check the Resizeable property to determine whether you accept the new value or not.
 
Although complex a lot can be done with design-time support, looking through these documents may get you some ideas: Extending Design-Time Support

It may be better to make ResizeType property an Enum type and add None as option (FormBorderStyle property is an example of this).
 
Back
Top