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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:24:57+00:00 2026-06-07T00:24:57+00:00

I have 2 pictureboxes on a panel at two separate locations which will become

  • 0

I have 2 pictureboxes on a panel at two separate locations which will become Hidden after a certain time. I would like to paint the pictureboxes background image to the panel at the exact points in which the picturebox controls lay. I have looked at the MSDN library but I cannot seem to find out how to do this.

Thanks for any help

  • 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-07T00:25:00+00:00Added an answer on June 7, 2026 at 12:25 am

    You can do something similar to this:

    Bitmap bitmap = new Bitmap(panel1.Size.Width, panel1.Size.Height);
    using (Graphics g = Graphics.FromImage(bitmap))
    {
        g.DrawImage(pictureBox1.BackgroundImage, new Rectangle(pictureBox1.Location, pictureBox1.Size));
        g.DrawImage(pictureBox2.BackgroundImage, new Rectangle(pictureBox2.Location, pictureBox2.Size));
        g.Flush();
    }
    
    pictureBox1.Visible = false;
    pictureBox2.Visible = false;
    panel1.BackgroundImage = bitmap;
    

    Or you can try using this:

    public class PanelEx : Panel
    {
        public PictureBox PictureBox1 { get; set; }
        public PictureBox PictureBox2 { get; set; }
        public bool IsBackgroundDrawn { get; set; }
    
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            if (!IsBackgroundDrawn)
            {
                IsBackgroundDrawn = true;
                base.OnPaintBackground(e);
            }
        }
    
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (PictureBox1 != null && PictureBox2 != null && !IsBackgroundDrawn)
            {
                Bitmap bitmap = new Bitmap(this.Size.Width, this.Size.Height);
                e.Graphics.DrawImage(PictureBox1.BackgroundImage, new Rectangle(PictureBox1.Location, PictureBox1.Size));
                e.Graphics.DrawImage(PictureBox2.BackgroundImage, new Rectangle(PictureBox2.Location, PictureBox2.Size));
                e.Graphics.Flush();
    
                PictureBox1.Visible = false;
                PictureBox2.Visible = false;
                this.BackgroundImage = bitmap;
                IsBackgroundDrawn = false;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a picturebox within my panel and I would like to fill
I have two controls which are both contained within a user control. Panel location:
I have many pictureboxes in my project and would like to know if there
In C# i have a picturebox. i would like to draw 4 colors. The
I have a large panel with lots of pictureBoxes inside it. Is it possible
I have a Panel which contains 20 PictureBox controls. If a user clicks on
I have a Panel which hosts a number of child controls in a grid
I have a form with a Panel which covers the entire form and serves
I have a Panel which is going to hold a lot of small UserControl
I have created a method which draws all the controls to the panel, but

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.