什么是使用C#改变字体大小的最简单方法。
使用Java可以通过调用带有必要参数的Font构造函数轻松完成所有操作。
JLabel lab = new JLabel("Font Bold at 24");
lab.setFont(new Font("Serif", Font.BOLD, 24));
yourformName.YourLabel.Font = new Font("Arial", 24,FontStyle.Bold);
如果你在表单所在的类中,那么可以这样做:
YourLabel.Font = new Font("Arial", 24,FontStyle.Bold);
构造函数接受不同的参数(因此选择你喜欢的)。像这样:Font(Font, FontStyle)
Font(FontFamily, Single)
Font(String, Single)
Font(FontFamily, Single, FontStyle)
Font(FontFamily, Single, GraphicsUnit)
Font(String, Single, FontStyle)
Font(String, Single, GraphicsUnit)
Font(FontFamily, Single, FontStyle, GraphicsUnit)
Font(String, Single, FontStyle, GraphicsUnit)
Font(FontFamily, Single, FontStyle, GraphicsUnit, Byte)
Font(String, Single, FontStyle, GraphicsUnit, Byte)
Font(FontFamily, Single, FontStyle, GraphicsUnit, Byte, Boolean)
Font(String, Single, FontStyle, GraphicsUnit, Byte, Boolean)
请参考这里
使用此选项仅更改字体大小而不更改字体名称
label1.Font = new System.Drawing.Font(label1.Font.Name, 24F);
使用Font类来设置控件的字体和样式。
Label lab = new Label();
lab.Text ="Font Bold at 24";
lab.Font = new Font("Arial", 20);
lab.Font = new Font(FontFamily.GenericSansSerif,
12.0F, FontStyle.Bold);
获取已安装字体请参考此链接 - .NET System.Drawing.Font - 获取可用的大小和样式
label1.Font = new Font("Serif", 24,FontStyle.Bold);
您还可以创建一个变量,然后将其分配给文本。这很酷,因为您可以将其分配给两个或更多的文本。
要分配变量,请执行以下操作
public partial class Sayfa1 : Form
Font Normal = new Font("Segoe UI", 9, FontStyle.Bold);
public Sayfa1()
这个变量还没有分配给任何文本。要做到这一点,写出文本的名称(查看属性->(名称)),然后写上“.Font”,接着调用你的字体变量的名称。
lupusToolStripMenuItem.Font = Normal;