用户登录
用户注册

分享至

使表单的背景透明

  • 作者: 丁硬扎大会啪啪
  • 来源: 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.

软件
前端设计
程序设计
Java相关