Dynamic label

leonard

New member
Joined
Dec 24, 2004
Messages
2
Location
Colorado
Programming Experience
10+
Please be easy with me. I'm a newbie. I have a form with 50 labels named status 1 - 50. I would like to change the back color of one.

I could use status2.Backcolor=System.Drawing.Color.Red and change the status2 button. I would like to make the "2" dynamic so I don't need 50 instructions to accomplish this on the rest of the labels. There probably is a very easy way to do this but like I said, I'm a newbie to vb.net.

Thanks in advance
leonard
 
Use a select case, case statement. If your changeing the color when the status buttons are clicked you will also use sender (sender is the button).

If you need me to explain it a bit more let me know.

TPM
 
TPM said:
Use a select case, case statement. If your changeing the color when the status buttons are clicked you will also use sender (sender is the button).

If you need me to explain it a bit more let me know.

TPM
Thanks.
I stuck a select in and it works ok. I was just hoping to get something a little more elegent than 50 case statements. It does work though. Actually I'm changing the background color of a label.
Thanks again.
 
Well you could use a for each to do it aswell. As in:

dim ctrl as control
for each ctrl in whatever
if ctrl.tag= 1 then
ctrl.backcolor = color.red
end if
next
 
Back
Top