【发布时间】:2021-08-20 21:44:28
【问题描述】:
我正在尝试从“设置”表单更改我的主表单的最顶部,但它不起作用。 代码如下:
private void button1_Click(object sender, EventArgs e)
{
if (this.button1.Text == "Top Most: ON")
{
this.button1.Text = "Top Most: OFF";
var main = new Main();
main.TopMost = false;
}
else if (this.button1.Text == "Top Most: OFF")
{
this.button1.Text = "Top Most: ON";
var main = new Main();
main.TopMost = true;
}
}
【问题讨论】:
-
var main = new Main();这不引用现有的主窗体。这是“新的”。
标签: c# winforms .net-core topmost