about uscontact

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 *

ZEMNA.NET

Professional software development agency estalished in Indonesia. We offers website setup, web application development, fulfillment service, and etc.
Follow us
Follow us to get latest news and tutorials.
2022 - Copyright, All Rights Reserved, Made by ZEMNA.NET with ❤️
magnifiercrossmenu