473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Color as Param

public LabelMsg(System.Web.UI.WebControls.Label lblMsg, string strMensagem,
Color.???)
{
lblMsg.Text = strMensagem;
lblMsg.ForeColor = clrLabel.???
}

I need to give the color as a param, wich type should i use ?
Nov 17 '05 #1
10 1592
Daniel Groh wrote:
public LabelMsg(System.Web.UI.WebControls.Label lblMsg, string strMensagem,
Color.???)
{
lblMsg.Text = strMensagem;
lblMsg.ForeColor = clrLabel.???
}

I need to give the color as a param, wich type should i use ?

system.color ?
JB
Nov 17 '05 #2
Daniel Groh wrote:
public LabelMsg(System.Web.UI.WebControls.Label lblMsg, string strMensagem,
Color.???)
{
lblMsg.Text = strMensagem;
lblMsg.ForeColor = clrLabel.???
}

I need to give the color as a param, wich type should i use ?

system.color ?
JB
Nov 17 '05 #3
No...there is System.Drawing.Color but it's not working as a reference!

if i do

System.Drawing.Color myColor

myColor.(point)...

it's showing to me properties that dont solve my probleb of textcolor!

"John B" <jb******@yahoo.com> escreveu na mensagem
news:42***********************@news.sunsite.dk...
Daniel Groh wrote:
public LabelMsg(System.Web.UI.WebControls.Label lblMsg, string
strMensagem, Color.???)
{
lblMsg.Text = strMensagem;
lblMsg.ForeColor = clrLabel.???
}

I need to give the color as a param, wich type should i use ?

system.color ?
JB

Nov 17 '05 #4
No...there is System.Drawing.Color but it's not working as a reference!

if i do

System.Drawing.Color myColor

myColor.(point)...

it's showing to me properties that dont solve my probleb of textcolor!

"John B" <jb******@yahoo.com> escreveu na mensagem
news:42***********************@news.sunsite.dk...
Daniel Groh wrote:
public LabelMsg(System.Web.UI.WebControls.Label lblMsg, string
strMensagem, Color.???)
{
lblMsg.Text = strMensagem;
lblMsg.ForeColor = clrLabel.???
}

I need to give the color as a param, wich type should i use ?

system.color ?
JB

Nov 17 '05 #5
Hello,
You can use this:

public LabelMsg(System.Web.UI.WebControls.Label lblMsg, string
strMensagem,System.Drawing.Color color);
{
lblMsg.Text = strMensagem;
lblMsg.ForeColor = color;
}

and later use it like this:
LabelMsg("Hello World","Hi World", Color.Red)

HTH. Cheers:)
Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #6
Hello,
You can use this:

public LabelMsg(System.Web.UI.WebControls.Label lblMsg, string
strMensagem,System.Drawing.Color color);
{
lblMsg.Text = strMensagem;
lblMsg.ForeColor = color;
}

and later use it like this:
LabelMsg("Hello World","Hi World", Color.Red)

HTH. Cheers:)
Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #7
Daniel Groh wrote:
No...there is System.Drawing.Color but it's not working as a reference!

if i do

System.Drawing.Color myColor

myColor.(point)...

it's showing to me properties that dont solve my probleb of textcolor!
Doh!
Knew I should have checked that first :)
It is still the correct type to use though.
What is it not doing that you want it to?

What is MyColor.(point)?

Color is static.

lblMyLabel.ForeColor = System.Drawing.Color.SteelBlue;

JB
"John B" <jb******@yahoo.com> escreveu na mensagem
news:42***********************@news.sunsite.dk...
Daniel Groh wrote:
public LabelMsg(System.Web.UI.WebControls.Label lblMsg, string
strMensagem, Color.???)
{
lblMsg.Text = strMensagem;
lblMsg.ForeColor = clrLabel.???
}

I need to give the color as a param, wich type should i use ?


system.color ?
JB


Nov 17 '05 #8
Daniel Groh wrote:
No...there is System.Drawing.Color but it's not working as a reference!

if i do

System.Drawing.Color myColor

myColor.(point)...

it's showing to me properties that dont solve my probleb of textcolor!
Doh!
Knew I should have checked that first :)
It is still the correct type to use though.
What is it not doing that you want it to?

What is MyColor.(point)?

Color is static.

lblMyLabel.ForeColor = System.Drawing.Color.SteelBlue;

JB
"John B" <jb******@yahoo.com> escreveu na mensagem
news:42***********************@news.sunsite.dk...
Daniel Groh wrote:
public LabelMsg(System.Web.UI.WebControls.Label lblMsg, string
strMensagem, Color.???)
{
lblMsg.Text = strMensagem;
lblMsg.ForeColor = clrLabel.???
}

I need to give the color as a param, wich type should i use ?


system.color ?
JB


Nov 17 '05 #9
That's tha way...I found it!

private void Page_Load(object sender, System.EventArgs e)
{
lblMsg.Text = "Testando parāmetro de cores";
SetColor(lblMsg,"Red");
}

private void SetColor(Label lblTexto, string strColor)
{
lblTexto.ForeColor = System.Drawing.Color.FromName(strColor); //This
method is the way --FromName--
}
--
Please, check my theSpoke:
http://www.thespoke.net/MyBlog/dgroh/MyBlog.aspx

"Maqsood Ahmed" <ma***********@gawab.com> escreveu na mensagem
news:eg****************@TK2MSFTNGP10.phx.gbl...
Hello,
You can use this:

public LabelMsg(System.Web.UI.WebControls.Label lblMsg, string
strMensagem,System.Drawing.Color color);
{
lblMsg.Text = strMensagem;
lblMsg.ForeColor = color;
}

and later use it like this:
LabelMsg("Hello World","Hi World", Color.Red)

HTH. Cheers:)
Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #10
Paperback Writer wrote:
That's tha way...I found it!

private void Page_Load(object sender, System.EventArgs e)
{
lblMsg.Text = "Testando parāmetro de cores";
SetColor(lblMsg,"Red");
}

private void SetColor(Label lblTexto, string strColor)
{
lblTexto.ForeColor = System.Drawing.Color.FromName(strColor); //This
method is the way --FromName--
}

UGLYYYYYY :)
Seriously, doing this is less intuitive, and way more fragile than
passing color as a color type.

I (or any future developers) can now break your code by doing
SetColor(lblmsg, "BlaBlaBla")

How about

private void SetColor(Label label, Color color)
{
label.ForeColor = color;
}
....
SetColor(myLabel, Color.Red);

Then, the programmer will get strong typing, (cannot pass an invalid
color), intellisense support etc..

Color.FromName will also incur a performance hit as well because it will
have to parse your string and map it to a valid colour.

HTH

JB
Nov 17 '05 #11

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

Similar topics

2
by: Michael.Suarez | last post by:
The code in my DLL: /// <summary> /// db_task..file_master_list /// </summary> /// <param name="panConnection"> /// Pass the PanApp.Connection object by reference /// </param> /// <param...
8
by: Michael.Suarez | last post by:
So I wrote a DLL in 2.0. An example of one of the funtions is: /// <summary> /// db_task..file_master_list /// </summary> /// <param name="panConnection"> /// Pass the PanApp.Connection object...
1
by: Rich | last post by:
Hello, I can update a dataset from my client app using a dataAdapter.Updatecommand when I add parameter values outside of the param declaration. But If I add the param values inline with the...
7
by: kforski | last post by:
Hello I wonder how can I find out if the param given to the xsl is defined without error during compilation. Actually I have such code (a part of it) <xsl:if test="$showWarnings='true']">...
4
by: Aussie Rules | last post by:
Hi, I have the Windows media object placed on a web page. Since its not a .net component (its a com object) I have placed the code in the html source of the page. The problem I am having is...
2
by: QTR | last post by:
Hello, I discovered a strange XSLT behaviour on Weblo 8.1. Let me explain it (see at the end my example XSLT): I call a template (1) with one parameter (A) which calls another template (2) with...
3
by: patelxxx | last post by:
Hi Guy's, Can you explain to me what is the 'Param Class' and what is it used for? I've just visited CPAN to find out what the Param Class however CPAN only shows the methods used by this class,...
2
by: mdejac | last post by:
I was wondering why the background color is not showing up in Mozilla. When I view the page there is a light blue background, when it should be black. Thank you for any help. ...
18
by: JohnDriver | last post by:
Hi, I am happy to say that with your help, I have been performing good in Ajax. Thanks for helping me to start with. I have a small problem now. I am pulling records from database and passing...
5
by: mdshafi01 | last post by:
HI, I have problem in this code it is not working it is not going insdie param condition... please what will be the problem please help me
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.