?
Solved

Properties and custom controls.

Posted on 2006-10-30
2
Medium Priority
?
184 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 1400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

743 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