I create a pictureBox on Run-time and then to access to it I use this code:
foreach(Control mycontrol in panel.Controls){
if(control.Name == "picBox1"){
//here I can work with my pictureBox
}
}
But once I am inside the if sentence I can’t put control.Image. Is there any property of Control which I could use to manage the picBox1’s Image property?
SOLUTION As Rajesh suggested, casting the control solves the problem. I was trying to cast it by using (PictureBox)control.Image and it was wrong.
The right way of doing it is writting Rajesh’s code: ((PictureBox)control).Image
Thanks for your help!
use the following code
Hope this helps.