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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:33:52+00:00 2026-05-26T10:33:52+00:00

I created a TransparentTableLayoutPanel: class TransTablePanel : TableLayoutPanel { public TransTablePanel() { } protected

  • 0

I created a TransparentTableLayoutPanel:

class TransTablePanel : TableLayoutPanel
{
    public TransTablePanel()
    {

    }

    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams createParams = base.CreateParams;
            createParams.ExStyle |= 0x00000020; // WS_EX_TRANSPARENT
            return createParams;
        }
    }

    protected override void OnPaintBackground(PaintEventArgs e)
    {
        // Do not paint background.
    }
}

And a transparent PictureBox (I tried just using BackColor = Transparent and it didn’t work)

class TransPicBox : PictureBox
{
    public TransPicBox()
    {

    }

    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams createParams = base.CreateParams;
            createParams.ExStyle |= 0x00000020; // WS_EX_TRANSPARENT
            return createParams;
        }
    }

    protected override void OnPaintBackground(PaintEventArgs e)
    {
        // Do not paint background.
    }
}

Here is the result:

enter image description here

First cell is the PictureBox with this paint event:

private void picBoxCompass_Paint(object sender, PaintEventArgs e)
    {
        Bitmap b = Properties.Resources.Compass_Rose;
        float rot = PitControl.GetPitbullRotation();
        e.Graphics.DrawImage(rotateImage(b, rot), 0, 0, picBoxCompass.Width, picBoxCompass.Height);
        e.Graphics.DrawLine(LinePen, picBoxCompass.Width / 2, 0, picBoxCompass.Width / 2, picBoxCompass.Height / 2);
        e.Graphics.FillPie(Brushes.Green, picBoxCompass.Width / 2 - 10, picBoxCompass.Height / 2 - 10, 20, 20, 0, 360);
    }

And you can see that is not Transparent (Black Background) and second cell is transparent (you can see my form’s background image).

How can i make the PictureBox Transparent ?

  • 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-05-26T10:33:53+00:00Added an answer on May 26, 2026 at 10:33 am

    Ok Iam adding code that worked for me. Its not very nice(I would like to hear how it could be done better), but maybe it will help you

    public class TransPicBox : Control
    {
        public Image Image
        {
            get;
            set;
        }
    
        public TransPicBox()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.SupportsTransparentBackColor, true);
            base.BackColor = Color.FromArgb(0, 0, 0, 0);//Added this because image wasnt redrawn when resizing form
        }
    
        protected override void OnPaintBackground(PaintEventArgs e)
        {
    
        }
    
        protected override void OnPaint(PaintEventArgs e)
        {
            if (Image != null)
            {
                e.Graphics.DrawImage(Image, 0, 0, Image.Width, Image.Height);
            }
        }
    
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.ExStyle |= 0x20;
                return cp;
            }
        }
    }
    

    You will need to set Image property.

    Edit: Note: Image should be with transparent background (tested with *.png format)

    Result:

    enter image description here

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

Sidebar

Related Questions

I created some class: class Base{ public: Base(int = 0); ~Base(); Base(Base&); Base(Derived&); //<-
I created a single page (with code behind .vb) and created Public intFileID As
I created a Rails application normally. Then created the scaffold for an event class.
created a c# console project, which contains a console class (program.cs). i added a
I created a class extending Application to have global variables in my app. I
I created a class and overridden the equals() method. When I use assertTrue(obj1.equals(obj2)) ,
Created a views.py method to get the data posted from an html form. As
Created .NET WCF service, tested it - works. Generated schemas from Data and service
I created a program using dev-cpp and wxwidgets which solves a puzzle. The user
I created a few mediawiki custom tags, using the guide found here http://www.mediawiki.org/wiki/Manual:Tag_extensions I

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.