[英]Changing TopMost of a form from another form
我正在尝试从“设置”表单更改我的主表单的最顶端,但它不起作用。 这是代码:
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;
}
}
在设置表单中:
private MainForm _mf;
public SettingsForm(MainForm mf){
InitializeComponent();
_mf = mf;
}
private void button1_Click(object sender, EventArgs e)
{
_mf.TopMost = !_mf.TopMost;
this.button1.Text == "Top Most: " + _mf.TopMost ? "ON" : "OFF;
}
在显示设置的主窗体中:
new SettingsForm(this).Show...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.