msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Default Value of Nothing for Property of type System.Drawing

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax
Author Message
Eric



Joined: 04 Oct 2007
Posts: 2

PostPosted: Fri Jan 05, 2007 11:17 pm    Post subject: Default Value of Nothing for Property of type System.Drawing Reply with quote

Hi Everyone,

Hopefully "vb.syntax" is the correct group for this question...

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:

_
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

_
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

Archived from group: microsoft>public>vb>syntax
Back to top
View user's profile Send private message
Eric



Joined: 04 Oct 2007
Posts: 2

PostPosted: Fri Jan 05, 2007 11:24 pm    Post subject: Re: Default Value of Nothing for Property of type System.Dra Reply with quote

Oops... I just realized... I think this is a vb6 group. My apologies.

--


Eric
eric@ejproductions.com



"Eric" wrote in message @TK2MSFTNGP03.phx.gbl...
> Hi Everyone,
>
> Hopefully "vb.syntax" is the correct group for this question...
>
> 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:
>
> _
> 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
>
> _
> 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
>
>
>

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Assigning Default Value to Object Property in Class Module I use a couple class modules in my projects to speed development and am looking to do the following: Private as Object Public Property Set vData As Object) Set = vData End Property Public Property Get Fiel

PictureBox rotation / XOR drawing Is there a way to rotate an image in a PictureBox in 90 degree increments or do I have to do it manually? And while I'm at it, I need to XOR various guide lines and markers on top of the image (and remove them easily, hence XOR) so I'd appreciate any idea

Printing Line Drawing Characters on an HP Laser printer I have been trying to print the line-drawing characters on an HP laserjet in order to reproduce a report previously generated by an HP mini computer. The characters are those that for the corners, sides and intersections of boxes and grids.

Default printer changes I'm using the common dialog in vb6 to change the default printer to send raw data to the printer. Then I attempt to change the default back to original default printer Currently the default printer (and other settings are picked up from common dialog and

Disabling the default F10 key behaviour. Hello everybody! I'm wondering if I could prevent the F10 key from activating my application's menus and assign it to a specific menu item (as with the other function keys). Any ideas? Thanks Howard
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group