Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Control Properties of Type System.Drawing.Color

Reply
Thread Tools

Control Properties of Type System.Drawing.Color

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      10-27-2008
I have a control with a property of type System.Drawing.Color. When I use
the control, the Property Grid in Visual Studio 2005 shows it, and even
gives me a dropdown list to select a color from. But it does not like the
value that gets put in the source. I get warnings like:

Generation of designer file failed: Cannot create an object of type
'System.Drawing.Color' from its string representation 'Green' for the
'BackgroundColor' property.

Am I not allowed to use colors as properties? Is there a property attribute
I need to add? It seems like a color should be a simple thing to add, since
there is only one value that needs specified in order choose it, and since
Visual Studio automatically gives me a list in the Property Grid to choose
from, I am assuming I am just missing something simple that I don't know
about. Any help would be appreciated. Thanks.
--
Nathan Sokalski
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
James Hahn
Guest
Posts: n/a
 
      10-27-2008
This is presumably a user control. What is your code for the
BackgroundColor property?

"Nathan Sokalski" <(E-Mail Removed)> wrote in message
news:e0qVQS$(E-Mail Removed)...
>I have a control with a property of type System.Drawing.Color. When I use
>the control, the Property Grid in Visual Studio 2005 shows it, and even
>gives me a dropdown list to select a color from. But it does not like the
>value that gets put in the source. I get warnings like:
>
> Generation of designer file failed: Cannot create an object of type
> 'System.Drawing.Color' from its string representation 'Green' for the
> 'BackgroundColor' property.
>
> Am I not allowed to use colors as properties? Is there a property
> attribute I need to add? It seems like a color should be a simple thing to
> add, since there is only one value that needs specified in order choose
> it, and since Visual Studio automatically gives me a list in the Property
> Grid to choose from, I am assuming I am just missing something simple that
> I don't know about. Any help would be appreciated. Thanks.
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
>


 
Reply With Quote
 
 
 
 
Nathan Sokalski
Guest
Posts: n/a
 
      10-27-2008
Actually, it is a custom control that inherits System.Web.UI.Control. My
code for the BackgroundColor property is:

Public WriteOnly Property BackgroundColor() As System.Drawing.Color
Set(ByVal value As System.Drawing.Color)
Me._backgroundcolor = value
End Set
End Property

Me._backgroundcolor is declared as:

Private _backgroundcolor As System.Drawing.Color

I know that my syntax for the property declaration is correct, I have used
it many times in other classes for other types (such as String, Integer,
etc.), just never with System.Drawing.Color. Any ideas? Thanks.
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/

"James Hahn" <(E-Mail Removed)> wrote in message
news:u9lfP2$(E-Mail Removed)...
> This is presumably a user control. What is your code for the
> BackgroundColor property?
>
> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
> news:e0qVQS$(E-Mail Removed)...
>>I have a control with a property of type System.Drawing.Color. When I use
>>the control, the Property Grid in Visual Studio 2005 shows it, and even
>>gives me a dropdown list to select a color from. But it does not like the
>>value that gets put in the source. I get warnings like:
>>
>> Generation of designer file failed: Cannot create an object of type
>> 'System.Drawing.Color' from its string representation 'Green' for the
>> 'BackgroundColor' property.
>>
>> Am I not allowed to use colors as properties? Is there a property
>> attribute I need to add? It seems like a color should be a simple thing
>> to add, since there is only one value that needs specified in order
>> choose it, and since Visual Studio automatically gives me a list in the
>> Property Grid to choose from, I am assuming I am just missing something
>> simple that I don't know about. Any help would be appreciated. Thanks.
>> --
>> Nathan Sokalski
>> (E-Mail Removed)
>> http://www.nathansokalski.com/
>>

>



 
Reply With Quote
 
Jeff Johnson
Guest
Posts: n/a
 
      10-27-2008
"Nathan Sokalski" <(E-Mail Removed)> wrote in message
news:er%(E-Mail Removed)...

> Actually, it is a custom control that inherits System.Web.UI.Control. My
> code for the BackgroundColor property is:
>
> Public WriteOnly Property BackgroundColor() As System.Drawing.Color
> Set(ByVal value As System.Drawing.Color)
> Me._backgroundcolor = value
> End Set
> End Property
>
> Me._backgroundcolor is declared as:
>
> Private _backgroundcolor As System.Drawing.Color
>
> I know that my syntax for the property declaration is correct, I have used
> it many times in other classes for other types (such as String, Integer,
> etc.), just never with System.Drawing.Color. Any ideas? Thanks.


Since this is derived from a Web class, I can't really help much, being a
desktop guy, but I have to wonder: why WriteOnly?


 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      10-27-2008
Sometimes when developing my controls I don't add the Get's until later so
that I can see more of the properties on the screen at once. And since it is
a control intended primarily for declarative usage, it will allow me to use
it normally when testing. Yes, I do plan on adding the Get's before putting
it on my site, and maybe I do have a strange style, but most of the controls
I write are simply for the enjoyment, so who cares?
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/

"Jeff Johnson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
> news:er%(E-Mail Removed)...
>
>> Actually, it is a custom control that inherits System.Web.UI.Control. My
>> code for the BackgroundColor property is:
>>
>> Public WriteOnly Property BackgroundColor() As System.Drawing.Color
>> Set(ByVal value As System.Drawing.Color)
>> Me._backgroundcolor = value
>> End Set
>> End Property
>>
>> Me._backgroundcolor is declared as:
>>
>> Private _backgroundcolor As System.Drawing.Color
>>
>> I know that my syntax for the property declaration is correct, I have
>> used it many times in other classes for other types (such as String,
>> Integer, etc.), just never with System.Drawing.Color. Any ideas? Thanks.

>
> Since this is derived from a Web class, I can't really help much, being a
> desktop guy, but I have to wonder: why WriteOnly?
>



 
Reply With Quote
 
James Hahn
Guest
Posts: n/a
 
      10-27-2008
That looks like proper Property set code to me. What is the line of code
that the designer is generating in the Sub InitializeComponent for a color
that you select in the Properties Settings?

"Nathan Sokalski" <(E-Mail Removed)> wrote in message
news:er%(E-Mail Removed)...
> Actually, it is a custom control that inherits System.Web.UI.Control. My
> code for the BackgroundColor property is:
>
> Public WriteOnly Property BackgroundColor() As System.Drawing.Color
> Set(ByVal value As System.Drawing.Color)
> Me._backgroundcolor = value
> End Set
> End Property
>
> Me._backgroundcolor is declared as:
>
> Private _backgroundcolor As System.Drawing.Color
>
> I know that my syntax for the property declaration is correct, I have used
> it many times in other classes for other types (such as String, Integer,
> etc.), just never with System.Drawing.Color. Any ideas? Thanks.
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Login control missing some properties in the properties pane Adam M ASP .Net 1 01-23-2008 10:06 PM
Designer Support: How to have user control's properties appear in IDE's properties window? Max2006 ASP .Net 2 07-13-2007 01:45 PM
Making Custom Control Properties Visible in Visual Studio's Properties Palette Nathan Sokalski ASP .Net Web Controls 0 10-17-2005 02:05 AM
Making Custom Control Properties Visible in Visual Studio's Properties Palette Nathan Sokalski ASP .Net 0 10-17-2005 02:05 AM
Making Custom Control Properties Visible in Visual Studio's Properties Palette Nathan Sokalski ASP .Net Building Controls 0 10-17-2005 02:05 AM



Advertisments