Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of canvas in Windows forms

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?

like image 764
Uthistran Selvaraj. Avatar asked Aug 08 '13 04:08

Uthistran Selvaraj.


2 Answers

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.

like image 76
VidasV Avatar answered Oct 13 '22 09:10

VidasV


If you want to create a Paint-like canvas, where you can draw simple graphics and images, you could use an instance of Graphics, like the following:

// myPictureBox is the control where your graphics will be drawn
Graphics myCanvas = myPictureBox.CreateGraphics();

If you want to display a group of images, like .jpg are displayed in the files explorer, you could use a ListView.

like image 25
Gark Garcia Avatar answered Oct 13 '22 08:10

Gark Garcia