• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 721
  • Last Modified:

UserControl Property - bindable

Hi,

I have created a Scrollable Control which has certain properties. One among them is a LinesStyle property which gets or sets an int value. This prooperty will be set through the desginger UI.

In the designer UI, I would like to have a small list box for this property which will contian values from 0 to 5 so that the designer cannot set values out of this range.

I could not get how to do this, even after setting the ListBindable(true).

Please let me know.

Thanks and Regards
Murali
0
bmmohan
Asked:
bmmohan
  • 2
  • 2
2 Solutions
 
TheAvengerCommented:
What about if you make it to be of an enumeration type and put in 5 values in the enumeration?
0
 
bmmohanAuthor Commented:
Hi  TheAvenger

Can you please eloborate this with some sample code?

Thanks and Regards
Murali
0
 
TheAvengerCommented:
Something like:

public enum LinesStyles {
  SuperThin = 0,
  VeryThin = 1,
  Thin = 2,
  Normal = 3,
  Thick = 4,
  VeryThick = 5
}

And then change the type of your property from int to LinesStyles. You can still use it in your code as int by casting it like:

int i = 1 + (int)this.lineStyle;
0
 
purpleblobCommented:
This is a very simple example of creating and using an enum. Place the public enum inside your control's class. m_LineStyle is a private member variable and obviously the Style property should be public. I've excluded code to force a redraw and check whether the value's actually changed.

public enum LineStyle
{
None,
Solid,
Dot      
}

private LineStyle m_LineStyle;

public LineStyle Style
{
   get { return m_LineStyle; }
   set { m_LineStyle = value; }
}
0
 
bmmohanAuthor Commented:
Hi TheAvenger and  purpleblob,

Thanks for the solution. It was very simple. I could do it successfully.

Thanks and Regards
Murali
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now