Solved

UserControl Property - bindable

Posted on 2003-11-16
5
705 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
  • 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 40 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 60 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
creating a flowchart from an algorithm 5 24
Exception in Log4Net 1 20
Expando 4 36
C# Reverse int in fast ways 6 29
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now