473,626 Members | 3,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Drawing. Color to String

Hello,

How do I convert a property of System.Drawing. Color to a string, i.e.,
"#FFFFFF"?

I have the following but it is not working:
MyColor.ToStrin g

Thanks,
Miguel

Oct 1 '07 #1
2 2323
You need to covert it to an appropriate rgb hex value - take a look at this
short example

http://www.mredkj.com/vbnet/GetHexColor.html

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"shapper" <md*****@gmail. comwrote in message
news:11******** *************@o 80g2000hse.goog legroups.com...
Hello,

How do I convert a property of System.Drawing. Color to a string, i.e.,
"#FFFFFF"?

I have the following but it is not working:
MyColor.ToStrin g

Thanks,
Miguel

Oct 1 '07 #2
"shapper" <md*****@gmail. comwrote in message
news:11******** *************@o 80g2000hse.goog legroups.com...
How do I convert a property of System.Drawing. Color to a string, i.e.,
"#FFFFFF"?

I have the following but it is not working:
MyColor.ToStrin g
There may be a built-in way, but I use this:

private string ColorToHex(Colo r pobjColor)
{
return "#" + string.Format(" {0:X2}{1:X2}{2: X2}", pobjColor.R,
pobjColor.G, pobjColor.B).To Lower();
}
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 1 '07 #3

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

Similar topics

7
14221
by: Toby Mathews | last post by:
Hi, In an ASP.Net application I want to convert open create a FileStream object from a System.Drawing.Image - is this possible? I create an instance of an Image object using the FromFile method, then use the GetThumbnailImage method to create a second Image. This second one is the one I want to get a FileStream from, so that I can then use its Handle to use Response.WriteFile to output the thumbnail on my ASP.Net page. Any help would...
0
2670
by: monkey king | last post by:
I have a given dll file(PDFCreator.dll) - probably generated by VC++. I want to use its method(PDFCreator()) in dotNet environment. It works well in WindiowsApplication, but bad in WebApplication ,the line that calls the function results in the "Object reference not set to an instance of an object" error. The following is the VB.NET code I am using to define the structures, declare the unmanaged DLL function and call the unmanaged DLL...
1
9571
by: Paul Hoad | last post by:
I'm trying to use MeasureString() to determine the length in pixels of a string However to do I need a System.Drawing.Graphics object to do this I need to create a System.Drawing.Graphics object for which there is only two constructors System.Drawing.Graphics.FromHdc
3
20063
by: anastasia | last post by:
I get an out of memory exception when attempting to excecute the following code: original = System.Drawing.Image.FromFile(file.FileName,true); I ONLY get this exception when the file is in the "My Documents" folder or subfolders. If the file lives anywhere else on the hard drive, I have no problems. What could be going on here?
1
3222
by: Hadar | last post by:
Hi, I'm getting "object is currently in use elsewhere" when I use System.Drawing.Graphics.MesureString. This is what I do: My controls use a utility class the helps it to mesure strings. To get the best performance for the utility class, its members, as well as the System.Drawing.Graphics object, are static:
10
12216
by: tshad | last post by:
I have a problem setting the background color of textbox on the fly. I tried using: applicantID.backcolor = "F6F6F6" and applicantID.backcolor = "#F6F6F6"
4
11110
by: Liverpool fan | last post by:
I have a windows application written using VB .NET that encompasses a countdown timer modal dialog. The timer is a System.Timers.Timer with an interval of 1 second. AutoReset is not set so accepts the default of True. The Elapsed event handler updates the dialog box with how long before it will close, acting as a timer itself. The dialog has a time to close property which is checked every time the Elapsed event fires. The problem I have...
3
4003
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user selects? thanks...
2
4497
by: =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= | last post by:
Hi, I am wondering why the .NET Framework is quite different from Win32 API when it comes to displaying system modal message boxes. Consider the four following types of system modal message boxes (please see associated source code below): 1) Win32 API with context ("btnWin32WithContext_Click") 2) .NET Framework with context ("btnFrameworkWithContext_Click") 3) Win32 API withOUT context ("btnWin32WithOUTContext_Click")
6
621
by: James Hahn | last post by:
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" <njsokalski@hotmail.comwrote in message news:er%23hyAFOJHA.1896@TK2MSFTNGP02.phx.gbl...
0
8203
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8711
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6125
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
5576
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
4094
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
4206
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1515
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.