如何在C#winodws表单中设置文本框的文本大小 [英] How to set text size as it is of text box in C# winodws form

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

问题描述

我有一个表格,其中有n个高度为9像素的文本框,我想允许文本字体大小为8.5像素但文本框不允许相同。

I have form in which there are n number of text boxses wihch of height 9 px and i want to allow text which is of font size 8.5 px but text box not allowing the same.

推荐答案



如果您使用字体Microsoft Sans Serif,8.25pt,在WinForm中,文本框的最小高度为20px。如果您将字体大小设置为1.5,则可能会将文本框高度设置为10px。这是非常难以理解的。



因此,如果您将文本框高度设置为9px,那么您将得到1px字体大小。如果你将文本框字体大小设置为8.5px,那么你的文本框高度将自动调整为20px。



无论如何设置字体大小的代码是

Hi,
In WinForm if you have font "Microsoft Sans Serif, 8.25pt" the minimum height you can have for the textbox is 20px. If you get the Font size to 1.5, the you might get the text box height to 10px. This is extremely unreadable.

So, if you set your text box height to 9px then you will get 1px Font Size. if you set the textbox font size to 8.5px then your textbox height will automatically adjust to 20px.

anyhow the code to set the font size is
textBox1.Font = new Font("Microsoft Sans Serif", 8.5f);





我希望这可以帮到你。



问候

Jegan



I hope this helps you.

Regards
Jegan


这篇关于如何在C#winodws表单中设置文本框的文本大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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