Custom Control Properties

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Turner

    #1

    Custom Control Properties

    When developing a custom control, lets say I have a property named
    "WidgetType " and
    this property can consist of 3 types "WidgetStandard , WidgetEnhanced,
    WidgetSimple".
    How does my control notify the IDE that these are the types of WidgetType so
    that the
    IDE can display a Listbox with these types ? Does this have to be an enum ?

    Many Thanks In Advance.


  • Bob Powell [MVP]

    #2
    Re: Custom Control Properties

    If you make it an enum the IDE will do the conversions fro you and display
    your enumeration values in the property grid.

    --
    Bob Powell [MVP]
    Visual C#, System.Drawing

    Find great Windows Forms articles in Windows Forms Tips and Tricks


    Answer those GDI+ questions with the GDI+ FAQ


    All new articles provide code in C# and VB.NET.
    Subscribe to the RSS feeds provided and never miss a new article.





    "Jon Turner" <jon.turner@mai l.com> wrote in message
    news:%235F2a6yS FHA.2256@tk2msf tngp13.phx.gbl. ..[color=blue]
    > When developing a custom control, lets say I have a property named
    > "WidgetType " and
    > this property can consist of 3 types "WidgetStandard , WidgetEnhanced,
    > WidgetSimple".
    > How does my control notify the IDE that these are the types of WidgetType
    > so that the
    > IDE can display a Listbox with these types ? Does this have to be an enum
    > ?
    >
    > Many Thanks In Advance.
    >[/color]


    Comment

    • Liu Xia

      #3
      RE: Custom Control Properties

      If you want to add enum properties in custom control,first declare an enum
      type like
      private widgettype _theenum;
      then add a property and set display style.
      [DefaultValue( widgettype.some thing ),Category("the Category")]
      public widgettype WidgetType
      {
      get
      {
      ...
      }
      set
      {
      ...
      }
      }

      "Jon Turner" wrote:
      [color=blue]
      > When developing a custom control, lets say I have a property named
      > "WidgetType " and
      > this property can consist of 3 types "WidgetStandard , WidgetEnhanced,
      > WidgetSimple".
      > How does my control notify the IDE that these are the types of WidgetType so
      > that the
      > IDE can display a Listbox with these types ? Does this have to be an enum ?
      >
      > Many Thanks In Advance.
      >
      >
      >[/color]

      Comment

      Working...