为什么我在运行应用程序时在表单中看不到变量 newGPUTextLabel

本文关键字:看不到 变量 表单 newGPUTextLabel 运行 应用程序 为什么 | 更新日期: 2024-09-23 20:55:38

private void GPULabels()
        {

                newGPUTextLabel.Location = new Point(340, 100);
                newGPUTextLabel.Height = 250;
                newGPUTextLabel.Width = 500;
                newGPUTextLabel.ForeColor = Color.Blue;
                newGPUTextLabel.Font = new Font("Arial", 35, FontStyle.Bold);
                newGPUTextLabel.Text = " - הטמפרטורה כעת";
                button3.Enabled = false;
                newGPULabel.Location = new Point(250, 100);
                newGPULabel.Height = 250;
                newGPULabel.Width = 500;
                newGPULabel.ForeColor = Color.Red;
                newGPULabel.Font = new Font("Arial", 35, FontStyle.Bold);
                button3.Enabled = false;
        }
        private void CPULabels()
        {
            temperature_label.Location = new Point(250, 200);
            temperature_label.Height = 250;
            temperature_label.Width = 500;
            temperature_label.ForeColor = Color.Red;
            temperature_label.Font = new Font("Arial", 35, FontStyle.Bold);
            textMode_label.Location = new Point(340, 200);
            textMode_label.Height = 250;
            textMode_label.Width = 500;
            textMode_label.ForeColor = Color.Blue;
            textMode_label.Font = new Font("Arial", 35, FontStyle.Bold);
            textMode_label.Text = " - הטמפרטורה כעת";
            button3.Enabled = false;
        }

我将标签添加到控件中,并为每个控件做了实例。我还在构造函数中调用这两个函数。

我在表单上看到所有标签,除了:newGPUTextLabel

Form1 大小为:800x600

如果我更改行:

newGPUTextLabel.Location = new Point(340, 100); 

newGPUTextLabel.Location = new Point(340, 10);

所以我看到了新的GPUTextLabel,但它在表单的顶部,我希望它靠近textMode_label。

为什么我在运行应用程序时在表单中看不到变量 newGPUTextLabel

根据您的描述,听起来好像newGPUTextLabel与其他控件不在同一容器中。

我会在设计器中查看它的添加位置(例如,其中一个控件可能位于面板或分组框中,而另一个可能不在(。