I am developing a new custom control in VisualStudio and wonder whether you can limit the property selection at design time.
To illustrate the problem, there are two properties that rely on each other – orientation and textside. The control itself is rectangular and the orientation can be either vertical or horizontal. What I want is to limit the textside property so that if the orientation is vertical the textside can only be left or right and if orientation is horizontal the textside can only be top or bottom.
Clearly you can do this at runtime within a set property method by checking other properties but what I would like to do this within the property window as design time so there is no chance of someone choosing the wrong combination of properties and then nothing or the wrong information is displayed when the project is run.
Currently I have this:
public enum VerticalTextSide { Left, Right }
public enum HorizontalTextSide { Top, Bottom }
public enum TextSide { }
public enum Orientation { Vertical, Horizontal }
private VerticalTextSide vts;
private HorizontalTextSide hts;
private TextSide db;
private Orientation or;
public TextSide textSide
{
get
{
if (or == Orientation.Vertical)
{
[need help!!]
}
else
{
[need help!!]
}
}
set
{
[need help!!]
}
}
public Orientation orientation
{
get
{
return or;
}
set
{
or = value;
}
}
Where I need help is to return and set the enum values depending on the orientation chosen. Maybe there is another way, perhaps?
Hopefully this is doable?
Thanks