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 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

Ask A Question

Stats

  • Questions 238k
  • Answers 238k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer var result = list.Where(i => IsItemEmpty(i)).FirstOrDefault(); This simple linq statement… May 13, 2026 at 6:48 am
  • Editorial Team
    Editorial Team added an answer I won't claim to know the answers to these questions,… May 13, 2026 at 6:48 am
  • Editorial Team
    Editorial Team added an answer Check out mono. It is an open source cross platform… May 13, 2026 at 6:48 am

Related Questions

I am struggling ( ! ) with java GUI development. All these small things
I need to display different drawings on a JPanel. I have put the drawing
I wish to draw an image based on computed pixel values, as a means
I am trying to create a custom CStatic control in vc++ and have a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.