Search code examples
c#winformspanelpicturebox

C# Panel or picturebox for drawing


Im looking to draw a map of dots(coordinates), i want to be able to select these dots later on by clicking on them. Is it better to use a picturebox for this or should i use a panel?

EDIT

Im drawing the dots from an array of values


Solution

  • When using a PictureBox, it's best to assign a Bitmap object to PictureBox.Image and then draw to the Bitmap, as that's how it's designed to work.

    If you want to use Panel, you should use your own class that inherits from Panel so you can set the options as follows. It's probably the best option if you need scrollbars:

    public class Canvas : Panel {
    
        public Canvas() {
            ResizeRedraw = true;
            DoubleBuffered = true;
        }
    }