Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Calling a PaintEventArgs in C# web form

  • 25-04-2006 08: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, Registered Users 2 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