Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 制作透明按钮_C#_Winforms_C# 4.0 - Fatal编程技术网

C# 制作透明按钮

C# 制作透明按钮,c#,winforms,c#-4.0,C#,Winforms,C# 4.0,我正在使用Winforms应用程序,并为Microsoft.NET Framework导入了Windows API代码包。下面是我的代码: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.For

我正在使用Winforms应用程序,并为Microsoft.NET Framework导入了Windows API代码包。下面是我的代码:

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
{
...
}
但当我试图在上面添加一个按钮时,结果是:


有人能告诉我如何使这里的按钮透明吗

如果您不能切换到WPF,我会使用GDI+并绘制矩形,它可以响应鼠标事件。现在你可以控制透明度了

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

这是一个新的应用程序吗?除非您要维护一些遗留应用程序或必须针对非常旧的操作系统,否则我建议使用WPF。WinForm最大的问题之一是透明度。如果你要用WinForm制作一个非常依赖透明性的应用程序,那么你正在走向一个受伤的世界。显然,如果你对WinForm非常了解,而WPF一点也不了解,那么这是一个更棘手的决定。但是如果你对这两方面都相当陌生或有经验,那么一定要选择WPF。同意@quibblesome,winforms不支持这一点。最好走(理智的)WPF之路。另外,为什么您的问题被标记为ASP.Net?