Welcome to Dream.In.Code
Become a C# Expert!

Join 150,396 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,035 people online right now. Registration is fast and FREE... Join Now!




Changing backcolor of a label.

 
Reply to this topicStart new topic

Changing backcolor of a label.

papuccino1
3 Mar, 2008 - 11:31 AM
Post #1

D.I.C Head
**

Joined: 2 Mar, 2008
Posts: 91


My Contributions
Here's my code:
CODE
if (this.label1.Text == numllamados[1])
            {
                this.label1.BackColor = Color.Blue;
            }



Is there a way I can make the if statement apply from label1---->label48? I don't want to make 48 ifs...

Maybe something like:

CODE
if (this.label1-48.Text == numllamados[1])
{
this.label1.BackColor = Color.Blue;
}

User is offlineProfile CardPM
+Quote Post

papuccino1
RE: Changing Backcolor Of A Label.
3 Mar, 2008 - 11:43 AM
Post #2

D.I.C Head
**

Joined: 2 Mar, 2008
Posts: 91


My Contributions
QUOTE(papuccino1 @ 3 Mar, 2008 - 12:31 PM) *

Here's my code:
CODE
if (this.label1.Text == numllamados[1])
            {
                this.label1.BackColor = Color.Blue;
            }



Is there a way I can make the if statement apply from label1---->label48? I don't want to make 48 ifs...

Maybe something like:

CODE
if (this.label1-48.Text == numllamados[1])
{
this.label1.BackColor = Color.Blue;
}



Hello???? Is anyone here???????

User is offlineProfile CardPM
+Quote Post

Jayman
RE: Changing Backcolor Of A Label.
3 Mar, 2008 - 12:44 PM
Post #3

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,327



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Not in a single IF statement. You will need to loop through all the label controls setting each one individually.
User is offlineProfile CardPM
+Quote Post

papuccino1
RE: Changing Backcolor Of A Label.
3 Mar, 2008 - 12:55 PM
Post #4

D.I.C Head
**

Joined: 2 Mar, 2008
Posts: 91


My Contributions
QUOTE(jayman9 @ 3 Mar, 2008 - 01:44 PM) *

Not in a single IF statement. You will need to loop through all the label controls setting each one individually.



Thank you for the answer smile.gif

I was afraid that was the case, so I went ahead and made the program.

Is it kosher if I post the executable here for you guys to give input and advice on improvments? I fell really proud because this is in effect, my FIRST ever game.

First of many more hopefully. pirate.gif
User is offlineProfile CardPM
+Quote Post

zakary
RE: Changing Backcolor Of A Label.
3 Mar, 2008 - 01:13 PM
Post #5

D.I.C Regular
Group Icon

Joined: 15 Feb, 2005
Posts: 420



Thanked: 8 times
Dream Kudos: 175
My Contributions
I dont think you can post exe here but you can post your code and we can compile it our selfs.
User is offlineProfile CardPM
+Quote Post

papuccino1
RE: Changing Backcolor Of A Label.
3 Mar, 2008 - 01:19 PM
Post #6

D.I.C Head
**

Joined: 2 Mar, 2008
Posts: 91


My Contributions
Edit: Thank you all for the help. Someone delete this topic now biggrin.gif

This post has been edited by papuccino1: 3 Mar, 2008 - 03:05 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 06:21PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month