在图C#透明窗体窗体、透明

2023-09-07 00:55:36 作者:单身求解放

我尝试创建一个显示在面板半透明形式。我可以显示的形式在面板,但不透明性不会工作的形式是不透明的。

im trying to create a semi-transparent form which is displayed in a panel. i can display the form in the panel but the opacity property wont work and the form is non-transparent.

private void button1_Click(object sender, EventArgs e)
{
      Form fr = new Form();
      fr.FormBorderStyle = FormBorderStyle.None;
      fr.BackColor = Color.Black;
      fr.TopLevel = false;
      fr.Opacity = 0.5;
      this.panel1.Controls.Add(fr);
      fr.Show();
}

任何想法如何,我可以处理这个问题? 感谢您的answeres!

any ideas how i can handle that? Thanks for your answeres!

推荐答案

的WinForms仅支持顶级形式部分透明。如果你想创建一个部分透明的UI元素的应用程序,您可能需要使用WPF,或处理所有的绘制自己。我很抱歉的坏消息。

Winforms only supports partial transparency for top-level forms. If you want to create an application with partially-transparent UI elements, you either need to use WPF, or handle all the drawing yourself. Sorry to be the bearer of bad news.