在相同的屏幕位置创建新表格 [英] Create new form on same screen position

查看:82
本文介绍了在相同的屏幕位置创建新表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在同一位置创建一个新表单.当我调用此代码时,会打开一个新表格,但是在不同的屏幕位置.

I want to create a new form on the same location. When I call this code a new form opens but on a different screen position.

private void BtnAddForm_Click(object sender, EventArgs e)
{
     Form2 form2 = new Form2();
     form2.Tag = this;
     form2.Location = this.Location;
     form2.Show(this);
     Hide();
}

我用this.Location从我的第一个表格中获取了位置,但这没有效果.

I used this.Location to get the location from my first form but this has no effect.

推荐答案

您需要将StartPosition属性设置为Manual才能起作用.

You need to set StartPosition property to Manual for this to work.

private void BtnAddForm_Click(object sender, EventArgs e)
{
    Form2 form2 = new Form2();
    form2.Tag = this;
    form2.StartPosition = FormStartPosition.Manual;         
    form2.Location = this.Location;
    form2.Show(this);
    Hide();
}

这篇关于在相同的屏幕位置创建新表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆