How do you set the color using hex value #6b8ec6 or the RGB

I want to set the DataGrid's header background color to #6b8ec6 but I could not find any method that allows me to do that on the following statements for example:

dg.HeaderStyle.BackColor = Color.SteelBlue;
dg.HeaderStyle.ForeColor = Color.White;
This one comes close but not sure what to pass in.
Color.FromArgb()
'Thanks for any help.
0
spatemp
1/20/2004 1:41:25 PM
asp.net.drawinggdi 1803 articles. 0 followers. Follow

6 Replies
1259 Views

Similar Articles

[PageSpeed] 57
Get it on Google Play
Get it on Apple App Store

Hi,

You can use the ColorTranslator come with the System.Drawing class
E.g.
Label1.BackColor = System.Drawing.ColorTranslator.FromHtml("#F9DA00")
Regards,
0
Colt
1/20/2004 1:42:55 PM
I would do what Colt recommends.

For future reference, Color.FromArbg() is called like:
Color.FromArgb(32,178,170);
Hope this helps.
Charley.
0
Charley
1/22/2004 11:14:38 PM
It seem that System.Drawing.ColorTranslator.FromHtml() only works with named colors ("red","green", ...) but not with hex values.

Is there a way to accept all formats and correctly transform to Color?
0
vmasanas
5/10/2004 2:07:38 PM
ColorTranslator works with hex...

You are most likely inputting it incorrectly.
What is the string you are using? "#FF0000"?
0
Charley
5/10/2004 2:37:07 PM
I'm calling and aspx page with a color param. I need this color to be passed on the querystring, so I call the aspx as:

somepage.aspx?color=#FFFFFF&....
and I get "Input string was not in a correct format". I think here the problem is the # symbol. Is there a problem passing # as a parameter?
If I write
somepage.aspx?color=FFFFFF
I get

FormatException: Input string was not in a correct format.]
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +0
System.ComponentModel.Int32Converter.FromString(String value, NumberFormatInfo formatInfo) +37
System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +382
[Exception: FFFFFF is not a valid value for Int32.]
System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +413
System.ComponentModel.TypeConverter.ConvertFromString(ITypeDescriptorContext context, CultureInfo culture, String text) +12
System.Drawing.ColorConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +984
System.ComponentModel.TypeConverter.ConvertFromString(String text) +9
System.Drawing.ColorTranslator.FromHtml(String htmlColor) +572
VMasanas.DNN.Modules.InfoMap.MapProcess.getMap(Boolean showGrid, Boolean showHotspots) +133
VMasanas.DNN.Modules.InfoMap.getMap.Page_Load(Object sender, EventArgs e) +250
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731

0
vmasanas
5/10/2004 9:45:40 PM
Try this:

System.Drawing.ColorTranslator.FromHtml("#" & Request.Querystring("color"))

Mikael Söderström
0
Vimpyboy
5/16/2004 9:20:33 PM
Reply:

Similar Artilces:

Set color using hex value instead of windows color?
Is there a way to set colors (in code) using hexidecimal values instead of windows colors: For example: UG1.Bands(0).RowAlternateStyle.BackColor = System.Drawing.Color.Honeydew Thanks! Traxon, UG1.Bands(0).RowAlternateStyle.BackColor = System.Drawing.ColorTranslator.FromHtml("#E3D5D5") Hope that helps... Many Thanks, Danny Cooper Aspose Excellent. Works great. Thank you very much. =)...

Use Hex Color Value as Background color in Gridview
Hello All,  What I'm doing is pulling a dataset which includes a background color field.  What I want to do is set the background color of that column to the value of the HEX value returned for that record.  What I'm getting is a can not convert to object error. I am using a boundfield control for the column I want to color.   Thanks in advanced.  D/New .NET Programmer I don't know exactly how the HEX color value is saved in your DB. Sth like this should work:int winColor = 0x009536DD; // HEX A, R, G, B GridView1.Rows[e.RowIndex].Cells[0].Bac...

Returning the Color Name from RGB or Hex values?
Hi, Me and a colleague of mine are working on a project that allows our users among other things to select from a drop down a color name (Red, Green, Blue, Magenta, etc etc) which will be used to color code training classes that they are entered for their training class web application. When we store the training class in the database, when it comes to the color value we do not store the name (red, green or blue), but instead the RGB integer value for the color. This works fine, however is there any way to retreive the Color Name from the RGB integer value? For example (let's say I ...

Passing colors in the code behind using a hex value
hey guysI have a problem over here passing a hex value for a colorunfortunately i do not have the name of the color but have the Hex value(#E0E0E0)but when i try to pass this value in the code behind page , its givin me an error.For eg: Control.BackColor = "E0E0E0"Can some give me the solution.Thanks if we see the code we might be able to tell !!Fadil Alnassar www.fadilalnassar.com | FREE Nodil Tab Controlhttp://www.mefranchising.com Try TextBox1.BackColor = System.Drawing.Color.FromArgb(0x0E, 0x0E, 0x0E);I would suggest a better approach to development technique.Instead of setting a co...

Setting Colors Using System Color Definitions
I want to be able to assign color to an object in a script, based on the way the user has their system colors defined. I know that the function RGB will allow me to specify a color, however I want to set the color of a field during runtime to one of the system colors, for example to "buttonface". When designing a datawindow, one is allowed to use the system colors as choices. I am assuming that this can also be done programmatically. Is there anyone who has done this, and if so how? Thanks for your help, Julie BUTTONFACE = 78682240 WINDOW_BACKGROUND = 10874349...

Using the value of a DropDown to set a value on a FormView
I have a FormView that I use to modify records.  The user selects which record to view by selecting a value from a DropDown.  The FormView has a datasource which is a SQLDataSource, which in turn uses Stored Procedures to modify the data. I have been able to get this to work with Selecting and Editing the records, but I can't get the Insert part to work properly.  The value that is selected from my DropDown (cboSpringLoads) is called "SpringLoadID" (an integer).  I can manually type this value in my FormView in Insert mode, but obviously, I can't expect...

use of uninitialized value: setting ENV values
I noticed in a recent make test: ext/XS/APItest/t/call......................................Use of uninitialized value in list assignment at ./test.pl line 504. ok This comes from t/test.pl: my @keys = grep {exists $ENV{$_}} qw(CDPATH IFS ENV BASH_ENV); local @ENV{@keys} = (); ... and apparently the warning occurs whenever you try to set an ENV value to undef: zen% perl -we '$ENV{FOO} = undef; use Data::Dumper; print Dumper($ENV{FOO})' Use of uninitialized value in scalar assignment at -e line 1. $VAR1 = undef; zen% I thought I remembered that ENV had speci...

Generating Color 3d-Chart in VB.NEt using 2 giving colors and number of colors as argument
I was wondering if anyone has an idea of how I can program a color-gradient value capturing function. My program will recieve 2 values as input ( StartColor and EndColor). The function will then return an array of 20 colors that exist between the two inputted colors. What I then intend to do with the values returned, is create an XML file and then using the gradient values to plot a 3d Chart or Graph. Does anyone have any idea how I can go about dealing with this? Can anyone help please?.NET Newbie...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

Data grid value used to set label value
I have a datagrid with a 'gender' field. In the database, it is either M or F. Only one record is returned Here's what I want to do. 1. Display in the datagrid Male if the database value is M and Female is the value is F. If that can't be done then here's option 2: 2. Change the text value of a label to Male if the database value is M ... I'm not sure how to look at a particular value in the datagrid. Very simple... Simply write a function that you call after binding the data to the grid, then loop through all datagrid items, pull the label value out, and change it ...

How to set color dynamically using html color codes??
 Hi,I want to do something like this: theGridView.FooterStyle.BackColor="#333333" , but having trouble finding right way to do it.How can the "#333333" be converted to a Color type?Thanks!  like this   theGridView.FooterStyle.BackColor = System.Drawing.ColorTranslator.FromHtml("#333333")  Mike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/...

set text color or background color in a gridview based on values
Is there a way to set font-clor or background-color of cells in a gridview? For example:  If the cell value is 0 : set font color/background-color to red, if value =10 set font-color/background-color to green?  Thanks                                                 A sample by using RowDataBound event. Add  OnRowDataBound="gv_RowDataBou...

how to set font color and bg color in a datagrid row using jscript
Hi there!, i just want to set font color and bg color in a datagrid row using jscript statically. Much Obliged & Thanks a Lot,Myself You mean something like this?    protected void gridLoginHistory_RowDataBound(object sender, GridViewRowEventArgs e)    {        if (e.Row.RowType.Equals(DataControlRowType.DataRow))        {            e.Row.Cells[0].Text = "" + ((((GridView)sender).PageIndex * ((GridView)sender).PageSi...

How to Retrive the store procedure return value in Ado.Net by using Dot Net?
Hi i am thiru. i try to create the small search engine. so that i have wrote the store procedure for it. thats given below.Create procedure FindtestThree @Name varchar(25), @Location varchar(25), @EmpId varchar(25) as select * from TbInfo where Name like + '%' + @Name + '%' select * from TbInfo where Location like + '%' + @Location + '%' select * from hi where ComName like + '%' + @EmpId + '%' Exec FindtestThree 'aa','a','d' ----------------------------------------- The above procedure return t...

Web resources about - How do you set the color using hex value #6b8ec6 or the RGB - asp.net.drawinggdi

Resources last updated: 12/6/2015 8:45:24 PM