rustyd Posted May 16, 2003 Posted May 16, 2003 I am building a control library. I have a text box, radio button, checkbox, and a usercontrol. I added 7 properties to the text box class. Here is an example of a string DefaultValue attribute I tried adding: <DefaultValue(GetType(String), "C"), _ Description("RICS Data Type (C=Char, N=Numeric)")> _ Public Property RICSType() As Char Get Return _RICSType End Get Set(ByVal Value As Char) _RICSType = Value End Set End Property In a different solution, I have the text box from the class on the toolbox. I drop a new, inherited text box onto a form, but the default value for string properties is null character. Here is the code: Friend WithEvents TextBox1 As RICSLIB.Ritext ... Me.TextBox1 = New RICSLIB.Ritext() ... Me.TextBox1.RICSType = Microsoft.VisualBasic.ChrW(0) Quote rustyd
*Gurus* divil Posted May 16, 2003 *Gurus* Posted May 16, 2003 Are you saying that the defaultvalue attribute you applied isn't working? I usually just use the constructor overload that accepts only a string but from looking at yours it should work - the default value in the propertygrid should be "C". You realise that attribute applies only to the propertygrid I take it? You still have to initialize the variable either in your constructor or on the declaration before the behaviour will be as you would expect. 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
rustyd Posted May 19, 2003 Author Posted May 19, 2003 Thanks, divil. I did not have them initialized in the constructor. Quote rustyd
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.