Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Property DefaultValue

2 views
Skip to first unread message

Meelis Lilbok

unread,
Mar 20, 2006, 3:22:00 AM3/20/06
to
Hi

Why does property default value not work?
When i start my application and dont set value from properties window
the value is always "nothing". Whats the point off DefualtValue then?

Regards;
Meelis


Private const cSaveText as string = "Save"
Private const cButtons as string = "Buttons"

<Description("Save button text"), Category(cButtons),
DefaultValue(cSaveText)> _
Public Property SaveButtonText() As String
Get
Return MySaveButtonText
End Get
Set(ByVal value As String)
MySaveButtonText = value
cmbSave.Text = value
End Set
End Property


Cerebrus

unread,
Mar 20, 2006, 4:19:17 AM3/20/06
to
Hi,

You need to initialize the variable "MySaveButtonText" as well, since
that is what you are *returning* in the Getter. For string variables, I
believe this is necessary.

Try adding the following line along with the Constant declarations :
---------------------------------------------------------
Private mySaveButtonText As String = cSaveText
---------------------------------------------------------

Hope this helps,

Regards,

Cerebrus.

Meelis Lilbok

unread,
Mar 20, 2006, 4:42:35 AM3/20/06
to
HI

Yes i allready have this (Private mySaveButtonText As String = cSaveText)
but this does not help.
If propertyvalue is not specified from property window, value is still
nothing.


Meelis

"Cerebrus" <zor...@sify.com> wrote in message
news:1142846357.4...@t31g2000cwb.googlegroups.com...

Cerebrus

unread,
Mar 20, 2006, 6:50:26 AM3/20/06
to
That *is* surprising, since it worked for me, when I copied and pasted
your code. Are you sure, the value is not getting changed elsewhere ?

Regards,

Cerebrus.

José Manuel Agüero

unread,
Mar 20, 2006, 6:56:57 AM3/20/06
to
Hello Meelis,

You should set the initial values in the constructor of your class.
The DefaultValue attribute is used by Visual Studio in the properties window: When you right click the property you will see a Reset item in the menu. It will reset the value to the one assigned in the DefaultValue attribute.

Regards.


"Meelis Lilbok" <meelis...@deltmar.ee> escribió en el mensaje news:e9v0Ud$SGHA...@TK2MSFTNGP09.phx.gbl...

Meelis Lilbok

unread,
Mar 20, 2006, 7:10:07 AM3/20/06
to
Hi and thnx José

But what when i want to change property in design mode and when no value is
entered for property
then defualtvalue is omitted automatically?


Regards;
Meelis


"José Manuel Agüero" <chema012 en hotmail.com> wrote in message
news:u$vKiVBTG...@TK2MSFTNGP11.phx.gbl...

José Manuel Agüero

unread,
Mar 20, 2006, 3:12:15 PM3/20/06
to
You can validate the input in the property set method of your component. It can ignore the wrong (or empty) value or throw an exception. In the latter case Visual Studio will show a message saying that the property value was invalid.

Regards.


"Meelis Lilbok" <meelis...@deltmar.ee> escribió en el mensaje news:e$PQycBTG...@tk2msftngp13.phx.gbl...

0 new messages