Font.ToString Font.ToString Font.ToString Font.ToString Method

定義

傳回這個 Font 的人們可解讀的字串表示。Returns a human-readable string representation of this Font.

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

傳回

表示這個 Font 的字串。A string that represents this Font.

範例

下列程式碼範例是針對與 Windows Forms 搭配使用所設計, 而且PaintEventArgs它需要e, 這Paint是事件處理常式的參數。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 該程式碼執行下列動作:The code performs the following actions:

  • 建立 FontCreates a Font.

  • 取得表示字型的字串。Gets a string that represents the font.

  • 在訊息方塊中顯示字串。Displays the string in a message box.

public:
   void ToString_Example( PaintEventArgs^ /*e*/ )
   {
      // Create a Font object.
      System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",16 );

      // Get a string that represents myFont.
      String^ fontString = myFont->ToString();

      // Display a message box with fontString.
      MessageBox::Show( fontString );
   }
public void ToString_Example(PaintEventArgs e)
{
    // Create a Font object.
    Font myFont = new Font("Arial", 16);
             
    // Get a string that represents myFont.
    string fontString = myFont.ToString();
             
    // Display a message box with fontString.
    MessageBox.Show(fontString);
}
Public Sub ToString_Example(ByVal e As PaintEventArgs)

    ' Create a Font object.
    Dim myFont As New Font("Arial", 16)

    ' Get a string that represents myFont.
    Dim fontString As String = myFont.ToString()

    ' Display a message box with fontString.
    MessageBox.Show(fontString)
End Sub

備註

傳回的字串具有下列格式:The returned string has the following format:

字體名稱 =fontName, 大小 =大小, 單位 =單位, GDiCharSet =GDiCharSet, GdiVerticalFont =布林值][Font: Name=fontName, Size=size, Units=units, GDiCharSet=gdiCharSet, GdiVerticalFont=boolean]

適用於