次の方法で共有


Font.ToString メソッド

この Font オブジェクトをユーザーが判読できる文字列形式で返します。

Overrides Public Function ToString() As String
[C#]
public override string ToString();
[C++]
public: String* ToString();
[JScript]
public override function ToString() : String;

戻り値

この Font オブジェクトを表す文字列。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • Font オブジェクトを作成します。
  • フォントを表す文字列を取得します。
  • 文字列をメッセージ ボックスに表示します。
 
Public Sub ToString_Example(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
        
[C#] 
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);
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

Font クラス | Font メンバ | System.Drawing 名前空間