Hi Guys
I am trying to make the windows Form BackColor Transparent but each time I try to set the BackColor to Transparent property I am encountering with following error message
Property Value is not Valid
Control does not support transparent background colors.

I also tried to add following code into Form1.Designer.cs, InitializeComponent() like :

private void InitializeComponent()
{
 this.BackColor = System.Drawing.Color.Transparent;
}

but I recived the following message
Control does not support transparent background colors.

I already tried to set both BackColor and TransparencyKey to same color like:

BackColor = Color.Lime;
TransparencyKey = Color.Lime;

but this is not what I am looking for.Can you please let me know how I can change the BackColor to transparent statues?

I've used this snippet before:

private void Form1_Load(object sender, EventArgs e)
        {
            //Hide our form from user
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            this.TransparencyKey = Color.FromKnownColor(KnownColor.Control);
            this.Update();
        }

Who the hell knows why microsoft decided that by default forms dont support a transparent back color...

Thanks skatamatic
This works fine, but can you let me know what is different between this method and setting the BackColor = Color.Lime;
TransparencyKey = Color.Lime;
into same color?

Thanks again for your time

Thanks skatamatic
This works fine, but can you let me know what is different between this method and setting the BackColor = Color.Lime;
TransparencyKey = Color.Lime;
into same color?

Thanks again for your time

I don't think there is a difference. You can, however, use the transperancy key to create a 'mask' of parts of the window you want to hide. Say some parts of the window are lime background, others are gray. Setting the key to gray will still leave the lime visible. This can create some fancy looking results (such as the Visual Studio 2010 Splash screen)

Really, this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); is the important part. Actually, I bet you can just set Background = System.Drawing.Color.Transparent after you set this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.