FontStyle 枚举
指定应用到文本的字形信息。
此枚举有一个 FlagsAttribute 属性,允许其成员值按位组合。
**命名空间:**System.Drawing
**程序集:**System.Drawing(在 system.drawing.dll 中)
语法
声明
<FlagsAttribute> _
Public Enumeration FontStyle
用法
Dim instance As FontStyle
[FlagsAttribute]
public enum FontStyle
[FlagsAttribute]
public enum class FontStyle
/** @attribute FlagsAttribute() */
public enum FontStyle
FlagsAttribute
public enum FontStyle
成员
成员名称 | 说明 | |
---|---|---|
Bold | 加粗文本。 | |
Italic | 倾斜文本。 | |
Regular | 普通文本。 | |
Strikeout | 中间有直线通过的文本。 | |
Underline | 带下划线的文本。 |
示例
下面的代码示例演示如何使用 FontStyle 枚举将按钮的 Font 属性设置为新的粗体样式。此示例是针对使用 Windows 窗体而设计的。创建一个包含名为 Button1 的按钮的窗体,并将下面的代码粘贴到该窗体中。将 Button1_Click
方法与该按钮的 Click 事件关联。
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If Not Button1.Font.Style = FontStyle.Bold Then
Button1.Font = New Font(FontFamily.GenericSansSerif, _
12.0F, FontStyle.Bold)
End If
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
if (Button1.Font.Style != FontStyle.Bold)
Button1.Font = new Font(FontFamily.GenericSansSerif,
12.0F, FontStyle.Bold);
}
private:
void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
Button1->Font = gcnew System::Drawing::Font( FontFamily::GenericSansSerif,12.0F,FontStyle::Bold );
}
private void button1_Click(Object sender, System.EventArgs e)
{
button1.set_Font(new Font(FontFamily.get_GenericSansSerif(), 12,
FontStyle.Bold));
} //button1_Click
平台
Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:2.0、1.0