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
Solved

Properties and custom controls.

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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 video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

792 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