Font.ToString Méthode

Définition

Retourne une représentation sous forme de chaîne, lisible par l'utilisateur, de ce Font.

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

Retours

Chaîne qui représente ce Font.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse, qui est un paramètre du Paint gestionnaire d’événements. Le code effectue les actions suivantes :

  • Crée un Font.

  • Obtient une chaîne qui représente la police.

  • Affiche la chaîne dans une boîte de message.

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

Remarques

La chaîne retournée a le format suivant :

[Font : Name=fontName, Size=size, Units=units, GDiCharSet=gdiCharSet, GdiVerticalFont=boolean]

S’applique à