StringFormat コンストラクター

定義

新しい StringFormat オブジェクトを初期化します。Initializes a new StringFormat object.

オーバーロード

StringFormat()

新しい StringFormat オブジェクトを初期化します。Initializes a new StringFormat object.

StringFormat(StringFormat)

指定した既存 StringFormat オブジェクトから、新しい StringFormat オブジェクトを初期化します。Initializes a new StringFormat object from the specified existing StringFormat object.

StringFormat(StringFormatFlags)

指定した StringFormatFlags 列挙体を使用して、新しい StringFormat オブジェクトを初期化します。Initializes a new StringFormat object with the specified StringFormatFlags enumeration.

StringFormat(StringFormatFlags, Int32)

指定した StringFormatFlags 列挙体および言語を使用して、新しい StringFormat オブジェクトを初期化します。Initializes a new StringFormat object with the specified StringFormatFlags enumeration and language.

StringFormat()

新しい StringFormat オブジェクトを初期化します。Initializes a new StringFormat object.

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

注釈

StringFormat クラスのインスタンスの初期プロパティ値を次の表に示します。The following table shows initial property values for an instance of StringFormat class.

プロパティProperty 初期値Initial Value
FormatFlagsFormatFlags 0 (フラグは設定されません)0 (no flags are set)
HotkeyPrefix None

StringFormat(StringFormat)

指定した既存 StringFormat オブジェクトから、新しい StringFormat オブジェクトを初期化します。Initializes a new StringFormat object from the specified existing StringFormat object.

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)

パラメーター

format
StringFormat

新しい StringFormat オブジェクトを初期化するために使用する StringFormat オブジェクト。The StringFormat object from which to initialize the new StringFormat object.

例外

formatnullです。format is null.

次のコード例は、次のメンバーを示しています。The following code example demonstrates the following members:

この例は、Windows フォームと共に使用するように設計されています。This example is designed to be used with Windows Forms. フォームにコードを貼り付け、フォームのShowLineAndAlignment Paintイベントを処理するときにメソッドを呼び出しePaintEventArgs、として渡します。Paste the code into a form and call the ShowLineAndAlignment method when handling the form's Paint event, passing e as 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

StringFormat(StringFormatFlags)

指定した StringFormatFlags 列挙体を使用して、新しい StringFormat オブジェクトを初期化します。Initializes a new StringFormat object with the specified StringFormatFlags enumeration.

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)

パラメーター

options
StringFormatFlags

新しい StringFormat オブジェクトの StringFormatFlags 列挙体。The StringFormatFlags enumeration for the new StringFormat object.

次のコード例は、次のメンバーを示しています。The following code example demonstrates the following members:

この例は、Windows フォームと共に使用するように設計されています。This example is designed to be used with Windows Forms. フォームにコードを貼り付け、フォームのShowLineAndAlignment Paintイベントを処理するときにメソッドを呼び出しePaintEventArgs、として渡します。Paste the code into a form and call the ShowLineAndAlignment method when handling the form's Paint event, passing e as 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

StringFormat(StringFormatFlags, Int32)

指定した StringFormatFlags 列挙体および言語を使用して、新しい StringFormat オブジェクトを初期化します。Initializes a new StringFormat object with the specified StringFormatFlags enumeration and language.

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)

パラメーター

options
StringFormatFlags

新しい StringFormat オブジェクトの StringFormatFlags 列挙体。The StringFormatFlags enumeration for the new StringFormat object.

language
Int32

テキストの言語を示す値。A value that indicates the language of the text.

適用対象