C#如何设置透明背景色?

wonderful_abc 2006-12-05 11:16:29
在构造方法private void InitializeComponent()中加入
SetStyle(System.Windows.Forms.ControlStyles.SupportsTransparentBackColor, true);
this.BackColor = System.Drawing.Color.Transparent;
可提示说“未找到方法System.Windows.Forms.Form.SetStyle”
何解?谢谢!
...全文
439 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
tianxingzh 2007-03-16
  • 打赏
  • 举报
回复
收藏!
wdy9927 2006-12-05
  • 打赏
  • 举报
回复
//对,是属性
//像下面这样,窗体就透明了。
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(192)), ((System.Byte)(192)));

this.TransparencyKey = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(192)), ((System.Byte)(192)));
wonderful_abc 2006-12-05
  • 打赏
  • 举报
回复
TransparencyKey在什么地方?
是什么类的属性吗(XXX.TransparencyKey)?
wonderful_abc 2006-12-05
  • 打赏
  • 举报
回复
To: junsir()
SetStyle()是个静态方法。
wdy9927 2006-12-05
  • 打赏
  • 举报
回复
可以通过设置TransparencyKey。

然后把 form 背景设置为相同的颜色,这样form就透明了。
junsir 2006-12-05
  • 打赏
  • 举报
回复
SetStyle()
这个方法你有定义吗?
在哪里定义的?

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧