简体   繁体   中英

Making a transparent button

I am working on a Winforms application and imported the Windows API Code Pack for the Microsoft .NET Framework. Below is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsAPICodePack.Taskbar;
using Microsoft.WindowsAPICodePack.Shell;    

namespace Glass_Test2
{
...
}

But when I tried to add a button on it, it turned out like:

在此处输入图片说明

Can any body tell me how to make the button here transparent?

If you can't switch to WPF, I would go with GDI+ and draw rectangles - which can respond to mouse events. Now you have control over transparency.

Public Class GDIButton
  Public Property Bounds As Rectangle
  Public Property Text As String
  Public Property BorderColor As Color
  Public Property FillColor As Color
End Class

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM