tags:

views:

22

answers:

2

HI

Let me explain what i wont to do.I have a form and there is 10 picturebox on it.when I click one of them I wont to hide all other except clicked.It is possible that on click event of all of them hide others.but I ask for efficent way.forexample with a single function call from click event maybe

A: 

Just write a function that accepts the Object. In that function you can loop through all those pictureboxes and compare it to the Object. If it's the Sender object you don't hide, otherwise you will.

Younes
I got it now.Thanks alot
gadirzade
A: 

I do not have .net installed on this computer but here is my solution.

Create a Tag for each control, then select all 10 pictureboxes and create one click event for them.

in the click event you can use this code, to loop through all controls and only hide the pictureboxes.

foreach (Control ctrl in Form1.Controls)
{
    if (ctrl.GetType() == typeof(PictureBox))
    { 
        if (((PictureBox)ctrl).Tag == ((PictureBox)sender).Tag)
        {
            ctrl.Hide();
        }
        else
        {
            ctrl.Show();
        }
    }
}

You might be able to compare the objects without Tags, but i can not test this without c# installed.

Michael Frey
Thank you.I try It and it works
gadirzade