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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:33:48+00:00 2026-06-10T03:33:48+00:00

When overriding an OnPaint or OnPaintBackground method in an inheritor of System.Windows.Forms.Control, one argument

  • 0

When overriding an OnPaint or OnPaintBackground method in an inheritor of System.Windows.Forms.Control, one argument is always a System.Windows.Forms.PaintEventArgs object. The partial object structure:

  • PaintEventArgs
    • ClipRectangle (System.Drawing.Rectangle)
    • Graphics (System.Drawing.Graphics)
      • Clip (System.Drawing.Region)
      • ClipBounds (System.Drawing.RectangleF)
      • VisibleClipBounds (System.Drawing.RectangleF)

Graphics.Clip appears to be a 1-bit map of applicable pixels to influence in subsequent paint operations.

MSDN: “Gets or sets a Region that limits the drawing region of this Graphics.”

Graphics.ClipBounds is a read only rectangle that appears to be the minimum rectangle to fully contain the Clip region.

MSDN: “Gets a RectangleF structure that bounds the clipping region of this Graphics.”

Graphics.VisibleClipBounds seems to be a more ‘intelligent’ clip, though I cannot understand how it operates.

MSDN: “Gets the bounding rectangle of the visible clipping region of this Graphics.”

ClipRectangle appears to in all cases duplicate the Graphics.ClipBounds property.

MSDN: “Gets the rectangle in which to paint.”

Can someone please answer the main question and potentially shed light on what all the various boundary objects are for?

Edit: added MSDN’s descriptions as per Dan-o’s answer.

  • 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-10T03:33:50+00:00Added an answer on June 10, 2026 at 3:33 am

    PaintEventArgs.ClipRectangle is the rectangle that actually needs to be drawn by your Paint event. Commonly equal to the size of the control’s client area. It will be smaller when only a portion of it was overlapped by another window. Or when you call its Invalidate(Rectangle) method. You can use it to skip drawing expensive objects that fall outside of that rectangle. Which is pretty rare, Windows itself already does a very good job of clipping what you draw.

    Graphics.Clip is a region that you can assign in your drawing code to clip what you draw yourself. It allows for various kinds of effects, like drawing an image clipped by a circle. Or really intricate clipping effects that use a GraphicsPath converted to a region.

    Graphics.ClipBounds is the rectangle around Graphics.Clip, it makes the math faster to get a first order estimate whether or not a point is outside of Graphics.Clip. You’ll get a meaningless “infinite” clip bounds if you never assigned the Clip property (X=-4194304,Y=-4194304,Width=8388608,Height=8388608)

    Graphics.VisibleClipBounds is the same as Graphics.ClipBounds but clipped also by the control window. So useful to test if a point might be inside the Clip region and visible to the user. If you never assign the Clip property then you’ll just get the size of the window.

    So it is Windows that sets PaintEventArgs.ClipRectangle. The rest is set by you by assigning the Graphics.Clip property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am overriding the OnPaint method in my control that I've made to draw
when overriding the loadView method in UIViewController, should one call [super loadView] in the
Im overriding an equals() method and I need to know if the object is
When overriding a method in Java is it possible to call the original one.
I am overriding the jumpRef method on a drop down control in the design
I'm overriding OnPaint in my control. At times, my control gets invalidated with a
I have a custom control in which I am overriding the following method to
I want to customize ToolStripMenuItem by overriding OnPaint function. This is a MyToolStripMenuItem: public
I am overriding the onBackPressed method in my app : public void onBackPressed() {
I'm overriding the draw method of CCLayerColor to draw a border, but the color

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.