I have some code that looks pretty simple and should draw an ellipse, but it doesn't seem to appear. Here is my code:
public partial class ThreeBodySim : Form
{
    public ThreeBodySim()
    {
        InitializeComponent();
        this.DoubleBuffered = true;
        Graphics graphics = displayPanel.CreateGraphics(); // Separate panel to display graphics
        Rectangle bbox1 = new Rectangle(30, 40, 50, 50);
        graphics.DrawEllipse(new Pen(Color.AliceBlue), bbox1);
    }
}
Am I missing something important?
Use the Paint() event to draw on your form. I recommend using a PictureBox on the form as it will not have as much flicker.
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        this.DoubleBuffered=true;
    }
    private void pictureBox1_Paint(object sender, PaintEventArgs e)
    {
        e.Graphics.SmoothingMode=System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        Rectangle bbox1=new Rectangle(30, 40, 50, 50);
        e.Graphics.DrawEllipse(new Pen(Color.Purple), bbox1);
    }
    private void pictureBox1_Resize(object sender, EventArgs e)
    {
        pictureBox1.Invalidate();
    }
}

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With