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 7848819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:20:28+00:00 2026-06-02T18:20:28+00:00

I am doing some revision for my comp103 paper and I cant get the

  • 0

I am doing some revision for my comp103 paper and I cant get the button with the Graphics.Clear(); method to clear the graphics paper. Can someone please point out the error in my code as I have spent about an hour trying to find an answer on the net.

Sorry for asking such a noob question.

Here is the code:

namespace Week_4_Ex1
{
    public partial class Form1 : Form
    {
        const int height1 = 150; // A constant that stores the flags height
        const int width1 = 100; // A constant that stores the flags width

        public Form1()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Button event that Draws a flag
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDraw_Click(object sender, EventArgs e)
        {
            Graphics Paper = this.CreateGraphics(); // Creates graphics paper to draw on
            Brush br1 = new SolidBrush(Color.Blue); // Creates a blue brush to draw with
            Brush br2 = new SolidBrush (Color.Orange); // Creates a orange brush to draw with
            Brush br3 = new SolidBrush (Color.Red); // Creates a red brush to draw with

            Pen Pen1 = new Pen(Color.Blue);         // Creates a blue pen to draw with
            Pen Pen2 = new Pen(Color.Orange);       // Creates a orange pen to draw with
            Pen Pen3 = new Pen(Color.Red);          // Creates a red pen to draw with

            //The following code draws a flag
            Paper.DrawRectangle(Pen1, 10, 10, width1, height1); // Draws a blue rectangle
            Paper.FillRectangle(br1, 10, 10, width1, height1); // Fills the rectangle with blue
            Paper.DrawRectangle(Pen2, 110, 10, width1, height1); // Draws a blue rectangle
            Paper.FillRectangle(br2, 110, 10, width1, height1); // Fills the rectangle with blue
            Paper.DrawRectangle(Pen3, 210, 10, width1, height1); // Draws a blue rectangle
            Paper.FillRectangle(br3, 210, 10, width1, height1); // Fills the rectangle with blue

        }
        /// <summary>
        /// Button that closes the form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close(); // Closes the form
        }

        /// <summary>
        /// Clears the picturebox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnErase_Click(object sender, EventArgs e)
        {
            Graphics.Clear(); //**THIS DOESN'T WORK**
        }

    }
}

Cheers,
Rab

  • 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-02T18:20:30+00:00Added an answer on June 2, 2026 at 6:20 pm

    try Graphics.Clear Method with color as below.

    this.CreateGraphics().Clear(Form1.ActiveForm.BackColor);  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just doing some revision, and one of the questions is: Explain what is meant
I'm doing some revision for an upcoming repeat :( and I've run into a
Hey, just doing some revision for upcoming exams and i'm looking at a past
I'm doing some research on revision control in practice, and there seems to be
I'm doing some revision on an old app that is written in classic ASP/VbScript.
I'm doing some revision of my C++, and I'm dealing with operator overloading at
Doing some jquery animation. I have certain divs set up with an attribute of
Doing some homework here (second assignment, still extremely green...). The object is to read
In doing some bioinformatics work, I've been pondering the ramifications of storing object instances
After doing some Core animations using: [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.5]; [self setAffineTransform:CGAffineTransformIdentity]; [UIView

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.