Mothra Posted November 24, 2003 Posted November 24, 2003 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). Quote Being smarter than you look is always better than looking smarter than you are.
*Experts* mutant Posted November 24, 2003 *Experts* Posted November 24, 2003 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 :). Quote
Mothra Posted November 25, 2003 Author Posted November 25, 2003 How do you get it to show in the property grid though? Quote Being smarter than you look is always better than looking smarter than you are.
*Experts* mutant Posted November 25, 2003 *Experts* Posted November 25, 2003 The property should be shown without any additonal work with the User Controls, I have no problem doing it. Quote
Mothra Posted November 25, 2003 Author Posted November 25, 2003 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 Quote Being smarter than you look is always better than looking smarter than you are.
*Experts* mutant Posted November 25, 2003 *Experts* Posted November 25, 2003 Using a String type will not work if you want to display a dropdown list like that. As far as what goes there: Return _myProperty :) Quote
Mothra Posted November 25, 2003 Author Posted November 25, 2003 (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 November 25, 2003 by Mothra Quote Being smarter than you look is always better than looking smarter than you are.
*Gurus* divil Posted November 25, 2003 *Gurus* Posted November 25, 2003 And that brings us back to mutant's original answer. Use an enumeration. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Voca Posted November 25, 2003 Posted November 25, 2003 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 Quote
Mothra Posted November 25, 2003 Author Posted November 25, 2003 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! Quote Being smarter than you look is always better than looking smarter than you are.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.