DefaultValue in control library

rustyd

Centurion
Joined
Mar 5, 2003
Messages
112
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)
 
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.
 
Back
Top