Font.ToString 方法
定义
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 窗体一起使用,并且它需要作为 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:
获取表示字体的字符串。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:
[Font: Name =fontName,size =size,units =units,GDiCharSet =GDiCharSet,GdiVerticalFont =boolean][Font: Name=fontName, Size=size, Units=units, GDiCharSet=gdiCharSet, GdiVerticalFont=boolean]