Solved

Properties and custom controls.

Posted on 2006-10-30
2
177 Views
Last Modified: 2010-04-16
Hello,

I am wondering if the following is possible.

I have a control called a ListButton. There is a property called ListWidthStyle. ListWidthStyle is actually a an enum which has
CustomWidth
ButtonWidth
LargestItemWidth

There is another property called ListWidth . What I am trying to do is ONLY allow them to set ListWidth in the properties window of my control if ListWidthStyle is set to CustomWidth. Otherwise it should be greyed out. So pretty much they should only be able to set the ListWidth in the properties window if CustomWidth is selected.

Is this possible?

Thanks!
- Steven
0
Comment
Question by:PoeticAudio
2 Comments
 
LVL 11

Accepted Solution

by:
Expert1701 earned 350 total points
ID: 17840090
The most you will be able to do is prevent them from creating an invalid combination (a non-zero ListWidth, and a ListWidthStyle other than ListWidthStyle.CustomWidth):

  ListWidthStyle listWidthStyle;

  [DefaultValue(typeof(ListWidthStyle), "CustomWidth")]
  public ListWidthStyle ListWidthStyle
  {
    get
    {
      return listWidthStyle;
    }
    set
    {
      listWidthStyle = value;

      if (listWidthStyle != ListWidthStyle.CustomWidth)
        listWidth = 0;
    }
  }

  int listWidth;

  [DefaultValue(0)]
  public int ListWidth
  {
    get
    {
      return listWidth;
    }
    set
    {
      if (listWidthStyle == ListWidthStyle.CustomWidth)
        listWidth = value;
      else
      {
        throw new ArgumentException("ListWidthStype must be set to CustomWidth");
      }
    }
  }
0
 
LVL 6

Author Comment

by:PoeticAudio
ID: 17847083
Okay, thanks
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
.NET Error 7 42
C# Problem Solving Execerscise 5 40
ConsoleSql 1 17
Is setting this variable making a duplicate in memory 4 12
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
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.

706 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

19 Experts available now in Live!

Get 1:1 Help Now