Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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)

rustyd
  • *Gurus*
Posted

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.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

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...