473,788 Members | 2,848 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RGB Colors

I'm using VB 2005.

When I select a color from the properties window for a control, it returns
an RGB color code (255,255,255). Now, when I attempt to assign a color in
code it is done using the COLOR.COLOROPTI ON value. How can I take an RGB
color set in the properties window and assign it via code. For example, I
have a control who's color is (192,255,192). I want to be able to also assign
this exact same color via code using the ControlName.Bac kColor property. I
tried doing ControlName.Bac kColor = RGB(192,255,192 ), but I get a message
stating "Value of Type Integer cannot be converted to System.Drawing. Color".

How can I assign an RGB Color to a BackColor via code?

Thanks.
Oct 30 '07 #1
3 12135
"Greg" <Ac**********@n ewsgroups.nospa mschrieb
I'm using VB 2005.

When I select a color from the properties window for a control, it
returns an RGB color code (255,255,255). Now, when I attempt to
assign a color in code it is done using the COLOR.COLOROPTI ON value.
I don't know "COLOROPTIO N". Where is it declared?
How can I take an RGB color set in the properties window and assign
it via code. For example, I have a control who's color is
(192,255,192). I want to be able to also assign this exact same
color via code using the ControlName.Bac kColor property. I tried
doing ControlName.Bac kColor = RGB(192,255,192 ), but I get a message
stating "Value of Type Integer cannot be converted to
System.Drawing. Color".

How can I assign an RGB Color to a BackColor via code?
ControlName.Bac kColor = Color.FromArgb( 192,255,192)
Armin
Oct 30 '07 #2
I guess you wanna just make your program to fit different themes
automatically.

I have a stupid way to deal with that.
First, build a dictinary(of SomeRGBValue, COLOROPTION) by your code, using
enumeration e.g.
And you can get the COLOROPTION while you want to.

"Greg" <Ac**********@n ewsgroups.nospa mwrote in message
news:E4******** *************** ***********@mic rosoft.com...
I'm using VB 2005.

When I select a color from the properties window for a control, it returns
an RGB color code (255,255,255). Now, when I attempt to assign a color in
code it is done using the COLOR.COLOROPTI ON value. How can I take an RGB
color set in the properties window and assign it via code. For example, I
have a control who's color is (192,255,192). I want to be able to also
assign
this exact same color via code using the ControlName.Bac kColor property. I
tried doing ControlName.Bac kColor = RGB(192,255,192 ), but I get a message
stating "Value of Type Integer cannot be converted to
System.Drawing. Color".

How can I assign an RGB Color to a BackColor via code?

Thanks.
Oct 31 '07 #3
Hi Greg,

Armin has provided the correct solution to you. Control.BackCol or property
expects an object of type "System.Drawing .Color". You may use
Color.FromArgb( ) method to convert numeric RGB values to the
System.Drawing. Color object.

Note: the "RGB()" function you used in the VB2005 is a legacy VB function,
which convert the RGB values into an integer value, instead of the
System.Drawing. Color type object. So the VB2005 compiler will emit the
error message: "Value of Type Integer cannot be converted to
System.Drawing. Color". See the reference below:
http://msdn2.microsoft.com/en-us/lib...8b(VS.80).aspx

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Oct 31 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2510
by: aznFETISH | last post by:
I have a list of links that I ue on my page, I alternate background colors for these links in a table, I usually do it using a DB but this list of link is manually added into the page so my question, is it possible to alternate the row colors automatic and have it created from a list of URL's?
7
2901
by: Laszlo Zsolt Nagy | last post by:
Hello, How can I determine the number of colors used in an image? I tried to search on Google but I could figure out. I read the PIL handbook but I do not see how to do it. Can anyone help? -- Best regards, Laszlo
5
2423
by: Dan Jacobson | last post by:
What's Nielsen talking about in http://www.useit.com/alertbox/20040503.html http://www.useit.com/alertbox/20040510.html Can't a good browser keep track of visited vs. unvisited link colors? Is my site deficient as I have not messed with link colors? Does Nielsen address why all this can't be left up to the browser? Are link colors supposed to be special, like background images, to make a big impression?
3
3590
by: Marc | last post by:
Hi, maybe you guys know something I don't know... Is it possible (and how) to achieve the following: 1) A <BODY> with specific background-color, say blue. 2) A <DIV class='main'> (which contains the main content text of the page) with no colors assigned at all.
6
6160
by: Danny Lesandrini | last post by:
I'm using an Access database to drive a web site and the colors of various table backgrounds are stored in Access. I want users of the Access database to be able to select colors for the site, but my mappings between named colors, HEX values and the Long Integer values used in Access are not jibbing. Anyone have a nice list laying around? Danny J Lesandrini dlesandrini@hotmail.com
0
352
by: mark | last post by:
Somebody can explain me why if I put a color with SetPixel the color showed is of another value? For example: I've to draw a grayscale image. The color RGB(90,90,90) become RGB(40,45,60). In the Visual C++ 6 help I see: Return Values If the function succeeds, the return value is the RGB value that the function sets the pixel to. This value may differ from the color specified by crColor; that happens when an exact match for the specified...
6
2250
by: Mark | last post by:
Is there a programatic way to iterate through all the named colors? Something like: HtmlTable ht = new HtmlTable(); HtmlTableRow htr; HtmlTableCell htc; foreach (Color c in ) //I CAN'T FIND COLLECTION OF ALL COLORS { htr = new HtmlTableRow();
11
2263
by: Paul Smith | last post by:
I have a button on my web page the backcolor of which I want to change: btnSample.backcolor = ???????? I want the color to be Gainsboro However I enter Gainsboro or color.Gainsboro I have the blue wavy line indicating an error. Help!
1
1876
by: Demi | last post by:
I want to be able to define standard colors in a base form, then have child forms use those values instead of standard colors. Ex in my base form I want to do this: Color myColor = System.Drawing.SystemColors.Control; Then in my child form in the designer, I want to be able to enter "myColor" in the BackColor property.
5
14546
by: Stick | last post by:
Hi, I normally program in C++, and I'm trying to write this little tool in C#, but I quickly realized that I can't use pointers, so instead I need to create an array of 3 Color 's private Color cDay; private Color cNight; private Color cLuminous;
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.