Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
I'm creating a user control and I can't figure out how to put a property on it that has a list of values for to choose from at design time (in the property grid).
Being smarter than you look is always better than looking smarter than you are.
  • *Experts*
Posted

You could make the list of values an enumeration and then in the property grid it will show a dropdownlist.

If that is not what you are looking for correct me :).

Posted

I mean how to you structure the property declaration?

 


Private _myProperty As String

Public Property myProperty() as String
    Get
         'What goes here?
    End Get
    Set(ByVal Value As String)
         _myProperty = Value
    End Set
End Property

Being smarter than you look is always better than looking smarter than you are.
Posted (edited)
Using a String type will not work if you want to display a dropdown list like that.

 

That must be my problem. But that just brings back to my origional problem, how DO you get a dropdown list of properties??

Edited by Mothra
Being smarter than you look is always better than looking smarter than you are.
Posted

Hi,

 

I think your code has to be something like

protected _myPropVal as MyEnum

Enum MyEnum
  Val1
  Val2
  Val3
  ...
End Enum

Public Property MyProp as MyEnum
  Get
     Return _myPropVal
  End Get
  Set (ByVal Value as MyEnum)
     _myPropVal = Value
  End Set
End Property 

If I'm wrong pleasse correct me, but as far as I understood this should be the answer.

 

Voca

Posted
And that brings us back to mutant's original answer. Use an enumeration.

 

Right after I posted that, I remembered the enumeration. There are time when I feel that my brain is just doing its own thing! Thanks all!

Being smarter than you look is always better than looking smarter than you are.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...