dsrajapaksa / LMUPracticals

Hey, Just take a look at the repo and fork it and have fun to pass the subject :D This is for LMU Students !
1 stars 6 forks source link

set visible of a label according to the number of labels that need to set visible #1

Open RJSIMMONS opened 7 years ago

RJSIMMONS commented 7 years ago

Sir, i have a issue with a small code

i have 3 labels : lbl1, lbl2 and lbl3 and i their visible hidden

i want to write a for loop to active them visible using code , example:

label1.Visibility = Visibility.Visible;

but i need to enable those labels according to the number i'm giving

for an example if i said enable visible only 2 labels then it should enable lbl1 and lbl2

i tried to use below code but its wrong int x =2 for(int count=1;count<=x;count++) { lbl(count).Visibility = Visibility.Visible; }

can yout help ?

thanks

dsrajapaksa commented 7 years ago

You have to put it in to array of objects, Let's assume we have 4 labels

```
    Label[] lbls = { label1, label2, label3, label4 };
        foreach(Label labl in lbls)
        {

        }
RJSIMMONS commented 7 years ago

ill show you by next week sir if i couldn't fix it, ill keep trying