Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8891741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:49:06+00:00 2026-06-14T22:49:06+00:00

Im using System.Drawing.Graphics graphicsObj for drawing objects on System.Windows.Forms.Panel . What is wise method

  • 0

Im using System.Drawing.Graphics graphicsObj for drawing objects on System.Windows.Forms.Panel. What is wise method to store informations about old drawings? To remove last drawing during MouseMove event?

Do i have to remember Pen settings and cords?

Thanks 🙂

// edit. I think my question is not clear. I have a Panel. I treat it like a container for drawing.

I can draw multiple lines, circles, rectangles.

Every time i press the mouse (MouseDown), im want to start drawing new object. When i move mouse (MouseMove), object currently drawed has to change (for example line, like in paint). When i release the mouse (MouseUp), i want object i drawed to became constant.

Now, i tried to invoke graphicsObj.Clear(); method on MouseMove event, but it clears all drawed objects.

So i deduced, that i have to store informations about old drawed objects. And now, i have to make lists (vectors or so) and store informations about that objects? Or there is a method to avoid it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:49:08+00:00Added an answer on June 14, 2026 at 10:49 pm

    You should handle all painting in the Panel‘s Paint event, that is exactly what it’s there for.

    The Paint event gives you in its PaintEventArgs the Graphics object you should use. This will make sure your instructions are painted on every refresh, not just once.

    If you are deriving from Panel, override the OnPaint method instead.

    Edit after original question has been expanded:

    You should separate the logic of storing the data from the logic of displaying your data. The Graphics object’s purpose is to display existing data, not to store data.

    I think making Lists or other collection of the objects you are drawing is the best solution.
    You will also need flags to handle all the logic of what is a “live” object, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using System; using System.Drawing; using System.IO; using System.Security.Cryptography; using System.Text.RegularExpressions; using System.Windows.Forms; using System.Threading;
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Drawing.Imaging;
I am using the System.Drawing.Graphics.DrawLines(Pen pen, PointF[] points) method in a multithreaded application, but
I am currently using the System.Drawing.Graphics.DrawString() method in .Net to draw text on top
I have a program that draws some vector graphics using System.Drawing and the Graphics
Using .NET's System.Drawing.Graphics GDI stuff, I have a shape consting of two arrays of
I am trying to merge two images using C Sharp's System.Drawing.Graphics. Here is my
I'm using System.Drawing.Graphics.CopyFromScreen to grab a partial screenshot of the desktop. I've noticed some
Within the System.Drawing.Graphics namespace you can draw a polygon like this: using (Graphics g
using System; using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Runtime.InteropServices; using DirectShowLib;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.