Solved

Properties and custom controls.

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

772 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