E
Eric
Hi Everyone,
I'm writing a UserControl that exposes a property of the type
System.Drawing.Image, like this:
Public Property DefaultImage() As Image
Get
Return propDefaultImage
End Get
Set(ByVal Value As Image)
propDefaultImage = Value
SetImage()
End Set
End Property
The property behaves *mostly* as expected. What I'm having trouble with is
the behavior of the property at design-time. I would like to accomplish two
things:
1) When my control is placed on a form, in the property browser, my
DefaultImage property value is shown to be "(none)". This is correct,
except it is appearing in a bold font as if the value has been changed from
the default value. When the value is "(none)" I would like it to not be
bold.
2) When the developer defines the image by clicking the "..." browse button
and selecting a bitmap, all is well: the image is set and everything does
what was intended. However, in the property browser, if the developer
selects the property value and presses the [del] button on the keyboard, the
image is not removed. I would like this to occur.
If you look at the BackgroundImage property of a Form, you can see the
behavior I am trying to emulate. I *thought* the solution would just be to
define the DefaultValue() attribute for the property to be Nothing, like
this:
<DefaultValue(Nothing)> _
Public Property DefaultImage() As Image
....
DefaultValue() is overloaded 11 times and one of the possible arguments is
Object, so I figured Nothing would fit for that one. But it does not:
"Overload resolution failed...". I then tried all sorts of things like
this:
Dim NothingImage As System.Drawing.Image = Nothing
<DefaultValue(NothingImage)> _
Public Property DefaultImage() As Image
....
but I can't do that because DefaultValue() requires a constant. I can't
have a constant be an object, so... I'm stuck. There's got to be something
obvious that I'm missing. Any ideas?
Thank you for your help!!
Eric
I'm writing a UserControl that exposes a property of the type
System.Drawing.Image, like this:
Public Property DefaultImage() As Image
Get
Return propDefaultImage
End Get
Set(ByVal Value As Image)
propDefaultImage = Value
SetImage()
End Set
End Property
The property behaves *mostly* as expected. What I'm having trouble with is
the behavior of the property at design-time. I would like to accomplish two
things:
1) When my control is placed on a form, in the property browser, my
DefaultImage property value is shown to be "(none)". This is correct,
except it is appearing in a bold font as if the value has been changed from
the default value. When the value is "(none)" I would like it to not be
bold.
2) When the developer defines the image by clicking the "..." browse button
and selecting a bitmap, all is well: the image is set and everything does
what was intended. However, in the property browser, if the developer
selects the property value and presses the [del] button on the keyboard, the
image is not removed. I would like this to occur.
If you look at the BackgroundImage property of a Form, you can see the
behavior I am trying to emulate. I *thought* the solution would just be to
define the DefaultValue() attribute for the property to be Nothing, like
this:
<DefaultValue(Nothing)> _
Public Property DefaultImage() As Image
....
DefaultValue() is overloaded 11 times and one of the possible arguments is
Object, so I figured Nothing would fit for that one. But it does not:
"Overload resolution failed...". I then tried all sorts of things like
this:
Dim NothingImage As System.Drawing.Image = Nothing
<DefaultValue(NothingImage)> _
Public Property DefaultImage() As Image
....
but I can't do that because DefaultValue() requires a constant. I can't
have a constant be an object, so... I'm stuck. There's got to be something
obvious that I'm missing. Any ideas?
Thank you for your help!!
Eric