Friday, January 2, 2009

Transparent Button on Windows Forms

Hi,

  

I was working on some VB6 migration to C#.NET, in VB6 application developers have used some third party controls (e.g. SSRibbon provided by Sheridan 3_0) to create transparent Buttons (required when button is drawn on the background image of form and you want user to click over that part of background image).

 

When I tried to search the internet for a solution in .NET, I didn’t found anything usefull. May be because this is quite simple thing :)

 

But still we need to have the solution on internet, so that someone in need can find it.

So, all you need to do is to add these lines of code for your System.Windows.Forms.Button object. In my case I have named it as btnLink.

 

          btnLink.FlatStyle = FlatStyle.Flat; 

          btnLink.BackColor = Color.Transparent;

          btnLink.FlatAppearance.MouseDownBackColor = Color.Transparent;

          btnLink.FlatAppearance.MouseOverBackColor = Color.Transparent;

 

namste !

  Anugrah Atreya