如何设置面板不透明度... [英] How to set Panel opacity ...
本文介绍了如何设置面板不透明度...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我该如何设置面板的不透明度,例如窗体具有不透明度属性.
How can i set opacity of pannel, like for form there is opacity property.
推荐答案
您不能为面板设置不透明度:它是仅是顶层窗口(例如窗体)的功能-它是未为子窗口(例如Panel)启用的硬件功能.
您可以通过将面板背景颜色设置为零的Alpha值来做到这一点,但这不是很好!
You can''t set an opacity for a panel: it''s a function of top level windows (such as forms) only - it is a hardware function that isn''t enabled for child windows such as Panel.
You can - sort of - do it, by setting the panel background colour to an Alpha value of zero, but...it''s not very good!
public frmMain()
{
InitializeComponent();
myPanel.BackColor = Color.FromArgb(0, Color.Black);
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawLine(Pens.Red, 0, 0, Width, Height);
}
这篇关于如何设置面板不透明度...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文