Condividi tramite


StringFormat Costruttori

Definizione

Inizializza un nuovo oggetto StringFormat.

Overload

StringFormat()

Inizializza un nuovo oggetto StringFormat.

StringFormat(StringFormat)

Inizializza un nuovo oggetto StringFormat dall'oggetto StringFormat specificato esistente.

StringFormat(StringFormatFlags)

Inizializza un nuovo oggetto StringFormat con l'enumerazione StringFormatFlags specificata.

StringFormat(StringFormatFlags, Int32)

Inizializza un nuovo oggetto StringFormat con l'enumerazione StringFormatFlags e la lingua specificate.

StringFormat()

Origine:
StringFormat.cs
Origine:
StringFormat.cs
Origine:
StringFormat.cs

Inizializza un nuovo oggetto StringFormat.

public:
 StringFormat();
public StringFormat ();
Public Sub New ()

Commenti

Nella tabella seguente vengono illustrati i valori iniziali delle proprietà di un'istanza della classe StringFormat.

Proprietà Valore iniziale
FormatFlags 0 (non sono impostati flag)
HotkeyPrefix None

Si applica a

StringFormat(StringFormat)

Origine:
StringFormat.cs
Origine:
StringFormat.cs
Origine:
StringFormat.cs

Inizializza un nuovo oggetto StringFormat dall'oggetto StringFormat specificato esistente.

public:
 StringFormat(System::Drawing::StringFormat ^ format);
public StringFormat (System.Drawing.StringFormat format);
new System.Drawing.StringFormat : System.Drawing.StringFormat -> System.Drawing.StringFormat
Public Sub New (format As StringFormat)

Parametri

format
StringFormat

Oggetto StringFormat da cui inizializzare il nuovo oggetto StringFormat.

Eccezioni

format è null.

Esempio

Nell'esempio di codice seguente vengono illustrati i membri seguenti:

Questo esempio è progettato per essere usato con Windows Forms. Incollare il codice in una maschera e chiamare il metodo quando si gestisce l'evento ShowLineAndAlignment del Paint modulo, passando e come PaintEventArgs.

private:
   void ShowLineAndAlignment( PaintEventArgs^ e )
   {
      // Construct a new Rectangle .
      Rectangle displayRectangle = Rectangle(Point(40,40),System::Drawing::Size( 80, 80 ));
      
      // Construct 2 new StringFormat objects
      StringFormat^ format1 = gcnew StringFormat( StringFormatFlags::NoClip );
      StringFormat^ format2 = gcnew StringFormat( format1 );
      
      // Set the LineAlignment and Alignment properties for
      // both StringFormat objects to different values.
      format1->LineAlignment = StringAlignment::Near;
      format1->Alignment = StringAlignment::Center;
      format2->LineAlignment = StringAlignment::Center;
      format2->Alignment = StringAlignment::Far;
      
      // Draw the bounding rectangle and a string for each
      // StringFormat object.
      e->Graphics->DrawRectangle( Pens::Black, displayRectangle );
      e->Graphics->DrawString( "Showing Format1", this->Font, Brushes::Red, displayRectangle, format1 );
      e->Graphics->DrawString( "Showing Format2", this->Font, Brushes::Red, displayRectangle, format2 );
   }
private void ShowLineAndAlignment(PaintEventArgs e)
{

    // Construct a new Rectangle .
    Rectangle  displayRectangle = 
        new Rectangle (new Point(40, 40), new Size (80, 80));

    // Construct 2 new StringFormat objects
    StringFormat format1 = new StringFormat(StringFormatFlags.NoClip);
    StringFormat format2 = new StringFormat(format1);

    // Set the LineAlignment and Alignment properties for
    // both StringFormat objects to different values.
    format1.LineAlignment = StringAlignment.Near;
    format1.Alignment = StringAlignment.Center;
    format2.LineAlignment = StringAlignment.Center;
    format2.Alignment = StringAlignment.Far;

    // Draw the bounding rectangle and a string for each
    // StringFormat object.
    e.Graphics.DrawRectangle(Pens.Black, displayRectangle);
    e.Graphics.DrawString("Showing Format1", this.Font, 
        Brushes.Red, (RectangleF)displayRectangle, format1);
    e.Graphics.DrawString("Showing Format2", this.Font, 
        Brushes.Red, (RectangleF)displayRectangle, format2);
}
Private Sub ShowLineAndAlignment(ByVal e As PaintEventArgs)

    ' Construct a new Rectangle.
    Dim displayRectangle _
        As New Rectangle(New Point(40, 40), New Size(80, 80))

    ' Construct two new StringFormat objects
    Dim format1 As New StringFormat(StringFormatFlags.NoClip)
    Dim format2 As New StringFormat(format1)

    ' Set the LineAlignment and Alignment properties for
    ' both StringFormat objects to different values.
    format1.LineAlignment = StringAlignment.Near
    format1.Alignment = StringAlignment.Center
    format2.LineAlignment = StringAlignment.Center
    format2.Alignment = StringAlignment.Far

    ' Draw the bounding rectangle and a string for each
    ' StringFormat object.
    e.Graphics.DrawRectangle(Pens.Black, displayRectangle)
    e.Graphics.DrawString("Showing Format1", Me.Font, Brushes.Red, _
        RectangleF.op_Implicit(displayRectangle), format1)
    e.Graphics.DrawString("Showing Format2", Me.Font, Brushes.Red, _
        RectangleF.op_Implicit(displayRectangle), format2)
End Sub

Si applica a

StringFormat(StringFormatFlags)

Origine:
StringFormat.cs
Origine:
StringFormat.cs
Origine:
StringFormat.cs

Inizializza un nuovo oggetto StringFormat con l'enumerazione StringFormatFlags specificata.

public:
 StringFormat(System::Drawing::StringFormatFlags options);
public StringFormat (System.Drawing.StringFormatFlags options);
new System.Drawing.StringFormat : System.Drawing.StringFormatFlags -> System.Drawing.StringFormat
Public Sub New (options As StringFormatFlags)

Parametri

options
StringFormatFlags

Enumerazione StringFormatFlags per il nuovo oggetto StringFormat.

Esempio

Nell'esempio di codice seguente vengono illustrati i membri seguenti:

Questo esempio è progettato per essere usato con Windows Forms. Incollare il codice in una maschera e chiamare il metodo quando si gestisce l'evento ShowLineAndAlignment del Paint modulo, passando e come PaintEventArgs.

private:
   void ShowLineAndAlignment( PaintEventArgs^ e )
   {
      // Construct a new Rectangle .
      Rectangle displayRectangle = Rectangle(Point(40,40),System::Drawing::Size( 80, 80 ));
      
      // Construct 2 new StringFormat objects
      StringFormat^ format1 = gcnew StringFormat( StringFormatFlags::NoClip );
      StringFormat^ format2 = gcnew StringFormat( format1 );
      
      // Set the LineAlignment and Alignment properties for
      // both StringFormat objects to different values.
      format1->LineAlignment = StringAlignment::Near;
      format1->Alignment = StringAlignment::Center;
      format2->LineAlignment = StringAlignment::Center;
      format2->Alignment = StringAlignment::Far;
      
      // Draw the bounding rectangle and a string for each
      // StringFormat object.
      e->Graphics->DrawRectangle( Pens::Black, displayRectangle );
      e->Graphics->DrawString( "Showing Format1", this->Font, Brushes::Red, displayRectangle, format1 );
      e->Graphics->DrawString( "Showing Format2", this->Font, Brushes::Red, displayRectangle, format2 );
   }
private void ShowLineAndAlignment(PaintEventArgs e)
{

    // Construct a new Rectangle .
    Rectangle  displayRectangle = 
        new Rectangle (new Point(40, 40), new Size (80, 80));

    // Construct 2 new StringFormat objects
    StringFormat format1 = new StringFormat(StringFormatFlags.NoClip);
    StringFormat format2 = new StringFormat(format1);

    // Set the LineAlignment and Alignment properties for
    // both StringFormat objects to different values.
    format1.LineAlignment = StringAlignment.Near;
    format1.Alignment = StringAlignment.Center;
    format2.LineAlignment = StringAlignment.Center;
    format2.Alignment = StringAlignment.Far;

    // Draw the bounding rectangle and a string for each
    // StringFormat object.
    e.Graphics.DrawRectangle(Pens.Black, displayRectangle);
    e.Graphics.DrawString("Showing Format1", this.Font, 
        Brushes.Red, (RectangleF)displayRectangle, format1);
    e.Graphics.DrawString("Showing Format2", this.Font, 
        Brushes.Red, (RectangleF)displayRectangle, format2);
}
Private Sub ShowLineAndAlignment(ByVal e As PaintEventArgs)

    ' Construct a new Rectangle.
    Dim displayRectangle _
        As New Rectangle(New Point(40, 40), New Size(80, 80))

    ' Construct two new StringFormat objects
    Dim format1 As New StringFormat(StringFormatFlags.NoClip)
    Dim format2 As New StringFormat(format1)

    ' Set the LineAlignment and Alignment properties for
    ' both StringFormat objects to different values.
    format1.LineAlignment = StringAlignment.Near
    format1.Alignment = StringAlignment.Center
    format2.LineAlignment = StringAlignment.Center
    format2.Alignment = StringAlignment.Far

    ' Draw the bounding rectangle and a string for each
    ' StringFormat object.
    e.Graphics.DrawRectangle(Pens.Black, displayRectangle)
    e.Graphics.DrawString("Showing Format1", Me.Font, Brushes.Red, _
        RectangleF.op_Implicit(displayRectangle), format1)
    e.Graphics.DrawString("Showing Format2", Me.Font, Brushes.Red, _
        RectangleF.op_Implicit(displayRectangle), format2)
End Sub

Si applica a

StringFormat(StringFormatFlags, Int32)

Origine:
StringFormat.cs
Origine:
StringFormat.cs
Origine:
StringFormat.cs

Inizializza un nuovo oggetto StringFormat con l'enumerazione StringFormatFlags e la lingua specificate.

public:
 StringFormat(System::Drawing::StringFormatFlags options, int language);
public StringFormat (System.Drawing.StringFormatFlags options, int language);
new System.Drawing.StringFormat : System.Drawing.StringFormatFlags * int -> System.Drawing.StringFormat
Public Sub New (options As StringFormatFlags, language As Integer)

Parametri

options
StringFormatFlags

Enumerazione StringFormatFlags per il nuovo oggetto StringFormat.

language
Int32

Valore che indica la lingua del testo.

Si applica a