Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

UserControl Property - bindable

Posted on 2003-11-16
5
Medium Priority
?
720 Views
Last Modified: 2012-06-21
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
Comment
Question by:bmmohan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9762063
What about if you make it to be of an enumeration type and put in 5 values in the enumeration?
0
 

Author Comment

by:bmmohan
ID: 9762095
Hi  TheAvenger

Can you please eloborate this with some sample code?

Thanks and Regards
Murali
0
 
LVL 20

Assisted Solution

by:TheAvenger
TheAvenger earned 160 total points
ID: 9762135
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
 
LVL 6

Accepted Solution

by:
purpleblob earned 240 total points
ID: 9762171
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
 

Author Comment

by:bmmohan
ID: 9768311
Hi TheAvenger and  purpleblob,

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

Thanks and Regards
Murali
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question