Solved

Properties and custom controls.

Posted on 2006-10-30
2
181 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
[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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

733 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