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 6757507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:39:43+00:00 2026-05-26T13:39:43+00:00

I want to draw some sort graphics on winform using following code : private

  • 0

I want to draw some sort graphics on winform using following code :

private void button1_Click(object sender, EventArgs e)
        {
            Pen myPen = new System.Drawing.Pen(Color.Red);
            Graphics handler = this.CreateGraphics();


            double[] nextPt = new double[2];
            double[] maurerPt = new double[2];
            for (int index = 1; index < 361; index++)
            {
                nextPt = calcRose(index * d);

                //this line is incorrect but Drawline only accept Point which is int
                //and valued are in fractions thats why I use double
                handler.DrawLine(maurerPt[0], maurerPt[1], nextPt[0], nextPt[1];

                nextPt.CopyTo(maurerPt,2);
            }

            myPen.Dispose();
            handler.Dispose();

        }

the problem is I want to create some sort of mathematic graph something called “maruer rose”
and since my lines value are in fractions so I can’t use Point which it only accept int values

how can I feed drawline with double or float value?

regards.

  • 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-05-26T13:39:44+00:00Added an answer on May 26, 2026 at 1:39 pm

    Hans should have posted his comment as an answer, but he is correct on both accounts. DrawLine() has an overload that accepts a PointF, so that’s not a problem.

    Your next issue will be figuring out why your graph seems to disappear randomly. You should do all of your drawing in a Control’s Paint event or, if in a derived class, by overriding OnPaint(), always drawing to the supplied Graphics object (e.Graphics).

    There will be times that your control repaints itself, perhaps because it was minimized, its dimensions were changed, whatever. Your code only paints when a button is clicked, which means that a system forced re-paint will wipe out your graph.

    Next, your code has a potential memory “leak”. What happens if anything between creating the pen/Graphics objects and calling Dispose() on them? In this specific case your program would likely just crash, but in general and more importantly, your calls to Dispose() will not occur and you have temporarily “leaked” some native resources.

    You should be wrapping the creation of types that implement IDisposable in using statements, i.e.

    using( var myPen = new System.Drawing.Pen(Color.Red) )
    using( var handler = this.CreateGraphics() )
    {
        // use 'myPen' and 'handler' here
    }
    

    This construct is actually a try/finally block, so even if something inside the curlies throws an exception Dispose() will still be called.

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

Sidebar

Related Questions

I have winform with a TextBox and I want to draw some GDI graphics
To get some smooth graphics, I want to draw oversampled by factor 2 and
I have some code in .Net to draw some text content using GDI+. I
I want to create some sort of graphical arrow, or possibly draw an arrow
I want to draw some lines and rectangles on a panel. Sometimes it does
I want to draw some listview items disabled and would like to mimic the
I have a ImageView and draw some things on that view. Now I want
In my program, I draw some quads. I want to add the functionality for
I want to draw some items on screen, each item is in one of
I am using the StarUml to draw some component dialog,however I found that it

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.