In this post, we'll learn how to create a transparent Form in Windows Form application. To make a transparent window, we need to change the opacity of the window.
- Click on File -> New Project and select Windows Forms Application.
- Click on the Form and select View Code
- Type the following code in the constructor.
this.TransparencyKey = (BackColor);
Now your entire code will be
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.TransparencyKey = (BackColor);
}
}
- Build and run your application either by CTRL + F5 or click on Start. 5)You will get a transparent form as shown below.
- To remove the border and to display a transparent image on the Form, First, add a Picture Box from the ToolBox and add a picture to it from Properties -> Background Image and select a transparent image from your computer.
- To fit the selected image in the Picture Box, change the BackgroundImageLayout property to Stretch.
- If you want to remove the border of the Form, go to properties of the form and change FormBorderStyle to None and Run your application.
Subscribe
Join the newsletter to get the latest updates.