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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:40:41+00:00 2026-05-11T05:40:41+00:00

I need to draw an image on a panel, containing some child controls. I

  • 0

I need to draw an image on a panel, containing some child controls. I dont want to let it hide behind those controls, which is the case right now when I’m drawing the image in the Paint event.

Here is the code I used to override the OnPaint method of my panel:

protected override void OnPaint(PaintEventArgs e) {     try     {         base.OnPaint(e);         //Draw icon for views at top right corner of the panel.         e.Graphics.SmoothingMode =                  System.Drawing.Drawing2D.SmoothingMode.HighQuality;         if (_viewButton != ViewButton.None)         {             Brush menuBrush =                  new SolidBrush(_viewButton == ViewButton.Highlighted ?                      Color.Black : Color.Gray);             e.Graphics.FillPolygon(menuBrush, new Point[] {                  new Point(this.Width - 29, 03),                  new Point(this.Width - 19, 03),                  new Point(this.Width - 24, 09) });             menuBrush.Dispose();              //Draw border of the panel.             Rectangle borderRect =                      new Rectangle(0, 0, this.Width - 1, this.Height - 1);             GraphicsPath borderPath = GetRoundPath(borderRect, 8);             e.Graphics.DrawPath(new Pen(Color.LightGray), borderPath);         }     }     catch (Exception ex)     {         throw new IDSException(ex);     } } 

protected override void OnPaint(PaintEventArgs e) {     try     {         base.OnPaint(e);         //Draw icon for views at top right corner of the panel.         e.Graphics.SmoothingMode =                  System.Drawing.Drawing2D.SmoothingMode.HighQuality;         if (_viewButton != ViewButton.None)         {             Brush menuBrush =                  new SolidBrush(_viewButton == ViewButton.Highlighted ?                      Color.Black : Color.Gray);             e.Graphics.FillPolygon(menuBrush, new Point[] {                  new Point(this.Width - 29, 03),                  new Point(this.Width - 19, 03),                  new Point(this.Width - 24, 09) });             menuBrush.Dispose();              //Draw border of the panel.             Rectangle borderRect =                      new Rectangle(0, 0, this.Width - 1, this.Height - 1);             GraphicsPath borderPath = GetRoundPath(borderRect, 8);             e.Graphics.DrawPath(new Pen(Color.LightGray), borderPath);         }     }     catch (Exception ex)     {         throw new IDSException(ex);     } } 
  • 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. 2026-05-11T05:40:41+00:00Added an answer on May 11, 2026 at 5:40 am

    The Paint event (or an override of the OnPaint method) is the wrong place to do this kind of thing, because you need to make sure that your painting routine is called last.

    Rather, if you have access to the parent control, override the OnPaint method, and then call the base implementation. Then draw your image, and it will be drawn on top of everything else.

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

Sidebar

Related Questions

i need to draw the following image The Gray part is what i want
I need to draw a .png image on an UIView. I have no clue
I am attempting to draw an image onto a CALayer. I only need an
I have a raw image buffer in the RGB format. I need to draw
I need to draw such a image like like.. a + mark at centre
I have a JPanel for which I set some image as the background. I
Need draw a graph with dot/graphviz like this image: The texts can be above
I have two controls which are both contained within a user control. Panel location:
I need to draw an image in mac os project. In iOS I can
i need draw some stuff on canvas and then lick on each. I made

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.