Form.Show() 稍微移动表单位置 [英] Form.Show() moves form position slightly

查看:22
本文介绍了Form.Show() 稍微移动表单位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它的主窗体充当一种框架,主窗体内有一个区域,我可以在其中打开其他窗体.这些表单永远不能关闭,因此当打开一个新表单时,我第一次使用此代码打开它:

I have an application with a main form that acts as a sort of frame and an area inside the main form where I open other forms. These forms must not be closed ever so when a new one is opened I use this code to open it for the first time:

frm.WindowState = FormWindowState.Maximized;
frm.BringToFront();

然后如果另一个表单在其上打开并且我需要再次显示它,我只需使用:

And then if another form gets opened on top of that and I need to show it again I just use:

frm.Show();

问题是当我第一次打开表单时,它的位置完美且边框排列得很好.当我使用 frm.Show() 将它带回来时,它会稍微向左和向下移动.知道为什么吗?

The problem is when I open the form the first time its positioned perfectly and the borders line up nice. When I use frm.Show() to bring it back it moves it slightly to the left and down. Any clue why?

推荐答案

您应该在表单属性窗口中将 StartPosition 属性设置为 'manual'

You should set the StartPosition property to 'manual' in form properties window

frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;

frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;

这篇关于Form.Show() 稍微移动表单位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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