Need to make a user control transparent

Category:
Author: zemna
Date: April 17, 2021
Share this:

To make your user control transparent, Add code described in three steps

Step 1

protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x00000020;
return cp;
}
}

Step 2

protected override void OnPaintBackground(PaintEventArgs e)
{
// dont code anything here. Leave blank
}

Step 3

protected void InvalidateEx()
{
if (Parent == null)
return;
Rectangle rc = new Rectangle(this.Location, this.Size);
Parent.Invalidate(rc, true);
}

After doing 3 steps, place your user control in the form. Its going to be transparents. The controls placed on user control will be visible.

Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *

Let's connect and create
something awesome together!
2023 - Copyright, All Rights Reserved, Made by ZEMNA.NET with ❤️
crossmenu linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram