在C#中更改TexBox字体 [英] Change TexBox Font in C#

查看:100
本文介绍了在C#中更改TexBox字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,
我想在运行时更改文本框字体!
请帮帮我.

示例:

我设计了一个带有文本框的表单.文本框字体为"Microsoft Sans Serif".现在我想将字体更改为"Tahoma".
我需要创建一个多语言应用程序.

请帮助我

Hi Friends,
I want to change a textbox font in runtime!
Please help me.

Example:

I designed a form with a textbox. the textbox font is "Microsoft Sans Serif". Now I want to change the font to "Tahoma".
I need to create a Multi Language Application.

Please help me

推荐答案

除了设置自己的字体外,还要考虑的另一件事是使用SystemFonts类

然后,它将使用用户当前在其外观设置中选择的字体

http://msdn.microsoft.com/zh-我们/library/system.drawing.systemfonts%28v=vs.85%29.aspx [
Instead of setting your own fonts, another thing to consider is using the SystemFonts class

This will then use the font the user has currently selected in their Appearance settings

http://msdn.microsoft.com/en-us/library/system.drawing.systemfonts%28v=vs.85%29.aspx[^]

e.g. set the font property of the form in your ctor

public class YourForm : Form
{
    public YourForm()
    {
        this.Font = SystemFonts.MessageBoxFont;
    }
}


您可以尝试这个
You can try this
textBox1.Font = new Font("Tahoma", 12);


TextBox1.Font = new Font(new FontFamily("Tahoma"), TextBox1.Font.Size, TextBox1.Font.Style, TextBox1.Font.Unit);



这样,如果您指定了样式,就可以保留样式.



This way you can retain the style if you have specified any.


这篇关于在C#中更改TexBox字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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