Equivalent of canvas in Windows forms

19,951

Solution 1

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.

Solution 2

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.

Share:
19,951
Uthistran Selvaraj.
Author by

Uthistran Selvaraj.

Updated on June 14, 2022

Comments

  • Uthistran Selvaraj.
    Uthistran Selvaraj. almost 2 years

    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?