Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 不透明度复选框(VisualStudio)don';行不通_C#_Visual Studio_Checkbox - Fatal编程技术网

C# 不透明度复选框(VisualStudio)don';行不通

C# 不透明度复选框(VisualStudio)don';行不通,c#,visual-studio,checkbox,C#,Visual Studio,Checkbox,没有代码问题,调试没有任何问题,但是当我测试时,当我选中复选框时,不透明度没有改变。什么也没发生。我正在使用VisualStudio 2013 Express。代码如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using Sy

没有代码问题,调试没有任何问题,但是当我测试时,当我选中复选框时,不透明度没有改变。什么也没发生。我正在使用VisualStudio 2013 Express。代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TP3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

            int carac = textBox1.Text.Length;
            label2.Text = carac.ToString();

        }

        private void label2_Click(object sender, EventArgs e)
        {




        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            Form Form1;
            Form1 = new Form1();
            if(checkBox1.Checked == true)
            {
             Form1.Opacity = 1;
            }


        }
    }
}

代码似乎没有做任何正确的事情。在
checkBox1\u CheckedChanged
方法(为什么要创建新表单?)中创建
Form
的新实例时,可以在新表单上设置不透明属性,但不能以任何方式显示表单。您需要调用
Form1
上的
Show()
/
ShowDialog()
来显示它

如果要更改当前窗体的不透明度,可以通过以下方式进行:

this.Opacity = 1;
像不使用
这个
这样的调用也可以:

Opacity = 1;

您不需要创建表单的新实例。