views:

49

answers:

3

Hi! I have a large panel with lots of pictureBoxes inside it. Is it possible to draw on these pictureboxes by drawing on the panel?

What i want is that the actual drawing is on top of the panel.

Is this possible to do, if so, how?

Thanks in advance

+1  A: 

You cannot do that if the pictureBoxes are inside the panel, what you may try is adding another panel inside it, above the pictures and drawing in that one. (Not sure if this would work either)

Francisco Soto
I have thought of that, but then i need a panel that is transparent, any idea of how to do that?
Maybe we would be able to help you better if you could tell us what you are trying to accomplish.
Francisco Soto
I'm loading lots of images in a panel.As a user scrolls inside the panel, the pictureboxes are deleted.If the user scrolls back to the area where he was, a thread loads back the images.Now i also want to be able to draw on these images, but i only have information of where to draw (by pixel) on the panel that holds all the pictureboxes.
If you want to draw only over the images I think you can easily do math to convert between panel pixels to pictureBox pixels and then draw over the particular image you want to.
Francisco Soto
I was hoping to not do that, but it looks like the best solution for now....
A: 

I would suggest rethinking this idea and drawing the pictures directly onto the panel. Then afterwards you could do the actual drawing that you require. You could create a custom class MyPanel or whatever, and inherit from Panel. Then override OnPaint and do all your drawing in there.

The only other way is to draw directly to the screen using link text.

AndrewVos
A: 

You can't draw on child controls in the parents OnPaint method, what you can do is hook into the OnPaintevent of every child control.

I would not recommend this however, I think it's better to create your own control which manages all the bitmaps.

Roy