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

  • Home
  • SEARCH
  • 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 7937839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:37:45+00:00 2026-06-03T22:37:45+00:00

In c# forms I have created a new paint method: private void thisPolygon(PaintEventArgs e)

  • 0

In c# forms I have created a new paint method:

private void thisPolygon(PaintEventArgs e)
{
    Pen clrBlue = new Pen(Color.Blue, 3);
    Point[] Wst = new Point[5];
    Wst[0] = new Point(20, 350);
    Wst[1] = new Point(110, 200);
    Wst[2] = new Point(200, 190);
    Wst[3] = new Point(210, 275);
    Wst[4] = new Point(190, 400);
    Wst[5] = new Point(50, 390);
    e.Graphics.DrawPolygon(clrBlue, Wst);
}

Now, how do I call it? I can’t make it work, this doesn’t work:

private void Form1_Load(object sender, EventArgs e)
{
    thisPolygon(); ///I've tried adding some stuff in brackets area, failed.
}
  • 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-06-03T22:37:47+00:00Added an answer on June 3, 2026 at 10:37 pm

    You have a few different problems.

    (1) Array Capacity. Your array is initialized with 5 storage locations, but you are attempting to set a sixth value.

    Point[] Wst = new Point[5]; // 5 indexes
    ...
    Wst[5] = new Point(50, 390); // Tries to access a sixth, but is out of bounds
    

    Change this to.

    Point[] Wst = new Point[6];
    

    Remember that arrays are zero-based indexed.

    (2) Not using OnPaint. You’re calling thisPolygon in the OnLoad method, which won’t persist your drawing. Move your call to the OnPaint method of the form.

    protected override void OnPaint(PaintEventArgs e) {
        base.OnPaint(e);
        thisPolygon();
    }
    

    (3) Not passing PaintEventArgs. You’re not passing in any event arguments to your thisPolygon method, and it won’t even compile as it is. Pass in the paint arguments from the OnPaint method.

    protected override void OnPaint(PaintEventArgs e) {
        base.OnPaint(e); // Pass in e
        thisPolygon();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to symfony. I have created a registration form using the code:
I have a follow-up question to this one . I created a new form,
I have created two forms in my Windows Application. One Form acts as a
I have created Login forms and registration forms for a website. The form is
I have created a program with Windows Forms in C# and the architecture is
I have created a tab control and few forms. Each form opens in a
i have created an mvc3 web application that uses forms based authentication. one part
I have created a C# Windows Forms application which I've attempted to make as
I have written an event handler method and attached it to the Paint event
I have a Create new account page. The form is in page named Register.php

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.