如何将C#控件保持在表单的中心? [英] how to keep a C# control to the center of the form?

查看:89
本文介绍了如何将C#控件保持在表单的中心?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在开发一个最大化的C#应用​​程序。我在表单中使用选项卡控件,现在我想确保控件出现在屏幕中间。我想创建一个输入表单,并希望确保所有控件都出现在表单的中心。任何想法?

Hi,
I am developing a C# application which start maximized. I am using a tab control inside the form and now I want to make sure that the controls appear in the middle of the screen. I want to make an entry form and want to make sure that all the controls appear in the center of the form. Any ideas?

推荐答案

处理表单调整大小事件,并将新位置设置为

Handle the form resize event, and set the new Location to
X = (formWidth - tabWidth) / 2
Y = (formHeight - tabHeight) / 2


这篇关于如何将C#控件保持在表单的中心?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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