Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Calling a PaintEventArgs in C# web form

Options
  • 25-04-2006 9:13am
    #1
    Closed Accounts Posts: 29


    Hi,

    I am trying something simple, just trying to draw a pie chart on a web form. I wish to call a PaintEventArgs when a button click event is called. Below is my code
    protected void Button1_Click(object sender, EventArgs e)
        {
            //Creating an instance of DrawPieFloat
            this.Paint += new PaintEventHandler(DrawPieFloat);
        }
    
        public void DrawPieFloat( PaintEventArgs e)
        {
             // Create pen.
            Pen blackPen = new Pen(Color.Black, 3);
            // Create location and size of ellipse.
            float x = 0.0F;
            float y = 0.0F;
            float width = 200.0F;
            float height = 100.0F;
            // Create start and sweep angles.
            float startAngle = 0.0F;
            float sweepAngle = 45.0F;
            // Draw pie to screen.
            g.Graphics.DrawPie(blackPen, x, y, width, height, startAngle, sweepAngle);
        }
    

    The error I get is "The type or namespace name "PaintEventArgs" could not be found. I think what I am doing wrong is calling "this.Paint" which is a win form rather than a web form call.

    Any help would be great?


Comments

  • Registered Users Posts: 151 ✭✭sailorfoley


    Hey,

    your right. The paint event does not exist for Web Pages, it exists only in Windows Forms. To further answer your question - the type PaintEventArgs exists only in the System.Windows.Forms namespace.

    Web pages are HTML. What you want to do is when you click a button the chart re-draws? I would make a control that displays the chart on screen and when the button is clicked, change the chart in whatever way you want. The browser will then display the chart on screen with changes.

    Hope this helps


Advertisement