Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create transparent buttons in Visual Studio 2005 with C#

I have a user interface that requires placing some round buttons in a C# project with some data behind them. The buttons are System.Windows.Forms.buttons and I have used a GIF image with transparency to create them. However, the transparent areas aren't transparent. I've looked for references online but haven't found any suggestions for how to do this properly. There's some mention of doing it in Visual Studio 2008 but I need to keep this project in 2005. Any help or suggestion is appreciated.

like image 587
Sean Avatar asked Oct 14 '08 16:10

Sean


People also ask

How do I make a button transparent in C#?

Click the button that you want to make transparent. Select FlatStyle from Properties and set it to popup Now change the BackColor property to Transparent . This will make the button transparent.


2 Answers

I'm pretty sure you need to use PNGs with WinForms to get image transparency. I know I've used them successfully.

EDIT: When I used the PNGs, I was overlaying them with the Image control onto the Form1.BackgroundImage; I wasn't using them in buttons.

I think your best bet is to switch from using a button control to using an image control. You might also try changing the button style to flat (I think it was flat, maybe one of the other styles) and seeing if you can get the effect you want that way.

like image 100
ine Avatar answered Oct 16 '22 21:10

ine


Try this:

        Bitmap temp = new Bitmap(button1.Image);

        temp.MakeTransparent(Color.Black); //your transparent color, in this case black

        button1.Image = (Image) Logo;

        temp.Dispose();

        temp = null;
like image 1
Bert Avatar answered Oct 16 '22 20:10

Bert