当我们最大化表单窗口时,如何使表单文本居中对齐? [英] how to align the form text in center when we maximize the form window?

查看:130
本文介绍了当我们最大化表单窗口时,如何使表单文本居中对齐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在制作GUI项目时,当我最大化屏幕时,我在居中对齐文本时遇到问题.即使我通过使用属性窗口增加了尺寸,执行时尺寸仍然保持不变.

While making GUI project i am facing problem in aligning the text in center when i am maximizing the screen.Even if i increased the size by using property window still the size remains same when i execute it.

推荐答案

在表格中使用div并对齐中心
Use a div inside form and align center
<form>
<div align="center">

</div>
</form>


您已经提到了文本的书写位置,无论是在标签,文本框等上.
如果文本写在标签上,则要保留文本在表格中居中的位置,请尝试以下替代方法.
1.如果需要在表单的顶部或底部放置标签,则可以使用label的 Dock 属性将标签停靠在表单的顶部或底部.
2.如果在其他位置需要标签,则将宽度设置为等于表单宽度,并将 Align 属性设置为 Top或Bottom and Left,Right ,因此调整表单大小时,标签也将调整大小.
在这两种情况下,都将 TextAlign 属性设置为 MiddleCenter ,以使文本在标签中居中,从而使文本也在窗体中居中.

如果解决了问题,则可以接受该解决方案;如果有问题,则可以发布查询.
You have mentioned where the text is written, whether on a label, textbox etc.
If the text is written on a label, to retain the text centered in the form you try the following alternatives.
1. If the label is required at the top or bottom of the form, then the label can be docked to the top or bottom of the form using the Dock property of label.
2. If the label is required at other location, then set the width equal to the form width, and set the Align property to Top or Bottom and Left,Right, so that when the form is resized, the label also gets resized.
In both the cases set the TextAlign property to MiddleCenter to keep the text centered in the label, so that the text is centered in the form too.

You may accept the solution if it solves your problem, or post your queries if any.


这篇关于当我们最大化表单窗口时,如何使表单文本居中对齐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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