Hi all,
Once I started learning C#, really much enjoying it. I faced some problem using GUI. I m trying to draw ellipse as many as possible with mouse moving events, but theres problem....

My code here:

private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            myRect.Width = 0;
            myRect.Height = 0;
            myRect.X = e.X;
            myRect.Y = e.Y;
        }

private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            Graphics g = this.CreateGraphics();
            Pen p = new Pen(Color.Red, 2);


            if (e.Button == MouseButtons.Left)
            {
                g.Clear(this.BackColor);

                myRect.Width = e.X - myRect.X;
                myRect.Height = e.Y - myRect.Y;
                g.DrawEllipse(p, myRect);

            }

        }

private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            Graphics g = this.CreateGraphics();

            Pen p = new Pen(Color.Green,4);

            g.DrawEllipse(p, myRect);
     //       g.Dispose();
        }

If you run this code, it works fine. BUT I cant draw ellipse continually, then only last one remains and previous one is deleted. BUT if I remove
g.Clear(this.BackColor); this line from mouseMove event, then I can draw ellipse as many as possible. But process shows shadow of the drawing which I want to remove. If you run both ways you might understand what Im trying to do.......

Pls help, urgent pls

thanks in advance

bagi

Hie bagi,

Im also new in VC#(GUI) but still i have knowledge of C#(Console Applications).

Can you please tell me which tool are you using ? as im unable to find the tool for draw ellipse.

Waiting for your reply!
PK:)

Tool? You mean talking about C#? You dont need to work on console if you use C#. You can work with interface which makes everything easy for you. I use Visual Studio . NET 2008, the lastest version. hope this help

bagi

Tool? You mean talking about C#? You dont need to work on console if you use C#. You can work with interface which makes everything easy for you. I use Visual Studio . NET 2008, the lastest version. hope this help

bagi

Hie again,

Yes, im also using Visual Studio .NET 2008.

What i want to know is.. What is "myRect" ??

Waiting for your reply!
PK:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.