我如何控制中心不调整呢? (.NET的WinForms) [英] How do I center controls without resizing them? (.net Winforms)

查看:117
本文介绍了我如何控制中心不调整呢? (.NET的WinForms)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个重新presents一个基本的登录控制一个相当简单的用户控件。所以它还有一些标签,文本框,和一个按钮。我想这个用户控件,以填补它的容器,所以我已经设置了被告席模式来填补。到目前为止,很容易。

I have a fairly simple user control that represents a basic login control. So it has a couple labels, text boxes, and a button. I would like this user control to fill its container, so I have set its dock mode to fill. So far easy enough.

现在,我想在我的用户控件的所有控件的基础上不论大小,我的用户控件时呈现为中心。我想不出一个锚/底座组合,会做的伎俩。

Now, I would like all the controls in my user control to be centered based on whatever size my user control is when rendered. I can't think of a anchor / dock combination that will do the trick.

用户控件有一个resize事件。所以我知道我可以计算,而在活动期间将根据我的用户控件的大小的控制。但是,我希望这个问题是共同的,足以通过设计来处理,如果我需要的。

The user control has a ReSize event. So I know I can calculate and move the controls based on my User control's size during that event. But I was hoping this issue was common enough to be handled through the designer if I desired.

推荐答案

看TableLayoutPanel控件,并用它与对接和锚固性能相结合。你应该能够控制布局相当precisely的方式。

Look at the TableLayoutPanel control and use it in conjunction with the docking and anchor properties. You should be able to control the layout fairly precisely that way.

这篇关于我如何控制中心不调整呢? (.NET的WinForms)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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