• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

Working with custom controls

I'm quite new to C#, so here is my probelm...

I have created a custom control that holds PictureBox (thumbnail) and Label control (image name).
In program I walk through directory for images and for each image i put my custom control on panel. By default custom control shows special icon instead of a thumbnail.

When all placeholders are set, I create a thread that process images in background  and when thumbnail created, change default icon with thumbnail.

If I change default icon with thumbnail "manually" like this..
MyControl1.pictureBox1.Image = new Bitmap(_image, width, height);

Problem arise when i create controls programaticaly. How do I find out "pointer/reference" to control?

for (int i = 0; i < this.my_panel.Controls.Count; i++)
... image processing...

?????????????.pictureBox1.Image = new Bitmap(_image, width, height);


Any ideas?
1 Solution
Hi gruntar,

> for (int i = 0; i < this.my_panel.Controls.Count; i++)
> {
> ... image processing...

(my_panel.Controls[i] as MyControl).pictureBox1.Image = new Bitmap(_image, width, height);

> }

gruntarAuthor Commented:
That was easy one. What was I thinking :D

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now