Equivalent of canvas in Windows forms

Uthistran Selvaraj. picture Uthistran Selvaraj. · Aug 8, 2013 · Viewed 16k times · Source

I am creating a simple app to display multiple images one below the other. In WPF, I used Number of canvas equivalent to number of images and added those canvas to the main canvas. And using Image control in each canvas, i uploaded the images with me and it is looking good.

Now, I Am trying to do the same in Windows forms. I tried Panel (as the main canvas in WPF) and draw images over it by using Panel_Paint event. it is fine. But I need to add something(as I added multiple canvas in WPF), but did not get strike any thing. I planned for few panels, but all them need Panel_Paint to draw images over it.That is some what difficult to maintain... any other ideas?

Answer

Vidas Vasiliauskas picture Vidas Vasiliauskas · Aug 8, 2013

You can create your own custom control and override OnPaint method. There you will be able to draw whatever you like in Canvas like mode. Create element specify its coordinates, draw it with Graphics object. And for overlaying use linear drawing order, items drawn later will be top most.