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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:14:06+00:00 2026-06-04T07:14:06+00:00

I am attempting to just draw basic shapes to a panel on my form.

  • 0

I am attempting to just draw basic shapes to a panel on my form. so far nothing happens and I dont know why. This method is called in the constructor of my form.

private void doGraphics()
    {
        Pen p = new Pen(Color.Black);//draws wire frame Shapes
        SolidBrush sb = new SolidBrush(Color.Yellow);//draws filled Shapes
        Graphics g = panel1.CreateGraphics();


        Point[] pointArray = { new Point(100, 20), new Point(100, 0), new Point(120, 0), new Point(120, 20) };
        g.FillPolygon(sb, pointArray);
        g.DrawPolygon(p, pointArray);
    }

Any suggestions would be great!

  • 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-04T07:14:07+00:00Added an answer on June 4, 2026 at 7:14 am

    You need to register to the Paint event of the panel and use the graphics object that comes with the arguments:

    In constructor:

    panel1.Paint += new PaintEventHandler(panel1_Paint);
    

    The handler itself:

    void panel1_Paint(object sender, PaintEventArgs e) {
    {
            Pen p = new Pen(Color.Black);//draws wire frame Shapes
            SolidBrush sb = new SolidBrush(Color.Yellow);//draws filled Shapes
            Graphics g = e.Graphics; // From Arguments
    
    
            Point[] pointArray = { new Point(100, 20), new Point(100, 0), new Point(120, 0), new Point(120, 20) };
            g.FillPolygon(sb, pointArray);
            g.DrawPolygon(p, pointArray);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to create a ListView where I can draw some basic shapes into
I just started working with jqGrid this week. I'm attempting to make a generic
Just attempting this question I found in a past exam paper so that I
I am just attempting to concatenate two strings in C and I don't know
I am attempting to create a custom messaging app. Just something basic but I
This is just an exercise in mechanics. I am attempting to create three custom
I'm just starting to teach myself objective-c and attempting to learn the cocoa touch
I'm attempting to transform crossdomain.xml for different environments, just like regular web.config files. I've
Attempting to use the data series from this example no longer passes the JSONLint
Attempting to make a NSObject called 'Person' that will hold the login details for

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.