# Panel Control in C#



## arpanmukherjee1 (May 19, 2010)

hello,
i have a panel.
i add label and a pictureBox using this :

```
private void AddLabelAndImage(ref Point startPoint, string labelText, System.Drawing.Image image)
        {
            Label label = new Label();
            panel1.Controls.Add(label);
            label.Text = labelText;
            label.Name = "text";
            label.Width = 100;
            label.Height = 30;
            label.Location = startPoint;
            startPoint.Y += label.Height;

            System.Windows.Forms.PictureBox box = new PictureBox();
            panel1.Controls.Add(box);
            box.Name = "image";
            box.Size = image.Size;
            box.Image = image;
            box.Location = startPoint;
            startPoint.Y += box.Height + 10;
```

what i want is to retrieve the picturebox control as System.Windows.Forms.PictureBox.
every function like find() returns Control[]

how to do this??


----------



## vamsi360 (May 27, 2010)

you have to returen the reference of the control i guess. I will try and tell you...


----------



## arpanmukherjee1 (May 27, 2010)

^ do you mean ::

PictureBox p1= panel1_ ????_


----------



## dheeraj_kumar (Jun 8, 2010)

It's simple.

Cast the Control returned to PictureBox.


----------



## Zangetsu (Jun 8, 2010)

arpanmukherjee1 said:


> hello,
> i have a panel.
> i add label and a pictureBox using this :
> 
> ...



u r using a subroutine.....& adding label & picturebox in panel.....
but i didnt get ur question...u want to get the picturebox then u can use
panel.findcontrol() method......


----------



## arpanmukherjee1 (Jun 9, 2010)

it's done. it returned PictureBox type .

thanks 2 u all 4 ur efforts...............


----------

