Font的Bold、Italic属性都是只读的,如何设置一个字体的这几个属性呢?

解决方案 »

  1.   

    可以这样设置this.Font = new Font("Arial", 12, FontStyle.Bold);
      

  2.   

    使用指定的大小、样式、单位和字符集初始化新的 Font。[Visual Basic]
    Public Sub New( _
       ByVal family As FontFamily, _
       ByVal emSize As Single, _
       ByVal style As FontStyle, _
       ByVal unit As GraphicsUnit, _
       ByVal gdiCharSet As Byte, _
       ByVal gdiVerticalFont As Boolean _
    )[C#]
    public Font(
       FontFamily family,
       float emSize,
       FontStyle style,
       GraphicsUnit unit,
       byte gdiCharSet,
       bool gdiVerticalFont
    );[C++]
    public: Font(
       FontFamily* family,
       float emSize,
       FontStyle style,
       GraphicsUnit unit,
       unsigned char gdiCharSet,
       bool gdiVerticalFont
    );[JScript]
    public function Font(
       family : FontFamily,
       emSize : float,
       style : FontStyle,
       unit : GraphicsUnit,
       gdiCharSet : Byte,
       gdiVerticalFont : Boolean
    );参数
    family 
    新 Font 对象的 FontFamily 对象。 
    emSize 
    新字体的全身大小(采用 unit 参数指定的单位)。 
    style 
    新字体的 FontStyle。 
    unit 
    新字体的 GraphicsUnit。 
    gdiCharSet 
    Byte,它指定用于此字体的 GDI 字符集。 
    gdiVerticalFont 
    一个布尔值,该值指示新字体是否由 GDI 垂直字体派生而来。
      

  3.   

    多谢二位的即时回复。
    但是,如果我希望这个font,是粗体并且是斜体,如何写呢,
    我写的
    Font font = new Font("Arial", 12, FontStyle.Bold, FontStyle.Italic,FontStyle.Underline);
    不能编译通过,还有其他办法吗?
      

  4.   

    想出来了,多谢!
    Font font = new Font("Arial", 20, FontStyle.Bold | FontStyle.Italic | FontStyle.Underline);