|
-
Feb 13th, 2003, 09:36 PM
#1
[HELP PLZ!!] I'm having a little problem setting the default value of a property
ahem, here's the property:
VB Code:
Private DEFAULT_FONT As Font = New Font ("Arial")
<DefaultValue(DEFAULT_FONT)> _
Public Overrides Property Font() As Font
Get
Return mFont
End Get
Set(ByVal Value As Font)
mFont = Value
End Set
End Property
It says that DEFAULT_FONT has to be a constant expression, but I cant declare a constant of type font.
What should I do? I just want to have a default value for the font property
Last edited by MrPolite; Feb 22nd, 2003 at 12:30 AM.
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 13th, 2003, 11:31 PM
#2
PowerPoster
You wouldn't want a default value for a font that you specify anyway. What if the user doesn't have that font installed? Your property will choke and errors will start to happen.
What you want to do is get the default system font. I am looking for that right now.
-
Feb 14th, 2003, 12:31 AM
#3
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 22nd, 2003, 12:30 AM
#4
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 22nd, 2003, 12:55 AM
#5
Maybe it'd be easier to set the defaults in the constructor or some other place then.
-
Feb 22nd, 2003, 02:33 AM
#6
well it's easy if I don't want to have a default property. I just want the user to be able to reset the color value to a default value. My problem is just with the DefaultValue attribute
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 22nd, 2003, 02:39 AM
#7
Well it seems as if the DefaultValue attribute only works with less complex data types that can be constants so I don't think that will work. Although you can set the default value when its created in the constructor and you can still give the user the ability to set the color back to default, just not with the DefaultValue attribute.
-
Feb 22nd, 2003, 12:55 PM
#8
PowerPoster
Originally posted by Edneeis
Well it seems as if the DefaultValue attribute only works with less complex data types that can be constants so I don't think that will work. Although you can set the default value when its created in the constructor and you can still give the user the ability to set the color back to default, just not with the DefaultValue attribute.
But if you put it in the constructor, wouldn't any modification the app develper does to the properties be voided as soon as the object is created durring run time?
-
Feb 22nd, 2003, 03:49 PM
#9
I don't think so I think the constructor only fires when the control is added to the form and if its just an object then it probably can't be set at designtime.
-
Feb 22nd, 2003, 07:43 PM
#10
Frenzied Member
I tried this to set the defaultvalue for font and it worked but reseting does not work and i dont know why. I tried shouldserialize and reset methods but no success till now
VB Code:
Dim mfont As New Font("Times New Roman", 20.0!)
<DefaultValue(GetType(System.Drawing.Font), "Times New Roman, 20pt")> _
Public Overrides Property Font() As Font
Get
Return mfont
End Get
Set(ByVal Value As Font)
mfont = Value
End Set
End Property
Last edited by Lunatic3; Feb 23rd, 2003 at 12:24 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|