Results 1 to 2 of 2

Thread: creating circle or square

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    creating circle or square

    hello!
    in vb6 you can simply drag and drop circle or the square,
    in c#.net how can i do that?

    thanks a bunch.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: creating circle or square

    You draw shapes in .NET using GDI+. You store the values that describe what you want to draw in control variables then you force the control on which you want to draw to repaint itself by calling its Refresh method or, preferably, its Invalidate and Update methods. This will raise the control's Paint event. You then read the values from the control variables in the control's Paint event handler and perform the appropriate drawing, e.g.
    Code:
    private Point centre;
    private int radius;
    
    private void DrawCircle(Point centre, int radius)
    {
        this.centre = centre;
        this.radius = radius;
        this.Refresh();
    }
    
    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        e.Graphics.DrawEllipse(Pens.Black,
                               centre.X - radius,
                               centre.Y - radius,
                               2 * radius,
                               2 * radius);
    }
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width