使表单的背景透明
- 作者: 丁硬扎大会啪啪
- 来源: 51数据库
- 2023-02-08
问题描述
如何使表单的背景透明?在 C# 中可以吗?
How I make a background transparent on my form? Is it possible in C#?
提前致谢!
推荐答案
您可以将表单的 BackColor 设置为不常见的颜色(例如 Color.Magenta)然后将表单的 TransparencyKey 属性设置为相同的颜色.然后,将 FormBorderStyle 设置为 None.
You can set the BackColor of your form to an uncommon color (say Color.Magenta) then set the form's TransparencyKey property to the same color. Then, set the FormBorderStyle to None.
当然,这只是快速简便的解决方案.控件的边缘很难看,您必须不断更改您添加的新控件的背景颜色(如果它们是按钮或类似的东西)以及一大堆其他问题.
Of course, that's just the quick and easy solution. The edges of controls are ugly, you have to keep changing the background color of new controls you add (if they're Buttons or something like that) and a whole host of other problems.
这真的取决于你想要实现什么.它是什么?如果你想做一个小部件之类的东西,有更好的方法.如果您需要圆角或自定义背景,还有更好的方法.因此,如果 TransparencyKey 不是您的想法,请提供更多信息.
It really depends what you want to achieve. What is it? If you want to make a widget sort of thing, there are much better ways. If you need rounded corners or a custom background, there are much better ways. So please provide some more information if TransparencyKey isn't quite what you had in mind.
- C#通过fleck实现wss协议的WebSocket多人Web实时聊天(附源码)
- 团队城市未满足要求:MSBuildTools12.0_x86_Path 存在
- 使用 MSBuild.exe 在发布模式下构建 C# 解决方案
- 当我发布 Web 应用程序时,AfterPublish 脚本不运行
- 构建时 T4 转换的产品仅在下一个构建中使用
- ASP.NET Core Application (.NET Framework) for Windows x64 only error in project.assets.json
- 新的 .csproj 格式 - 如何将整个目录指定为“链接文件"到子目录?
- 如何将条件编译符号(DefineConstants)传递给 msbuild
- MSBuild 支持 Visual Studio 2017 RTM 中的 T4 模板
- NuGet 包还原找不到包,没有源