StringFormat.ToString メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > StringFormat.ToString メソッドの意味・解説 

StringFormat.ToString メソッド

この StringFormat オブジェクトユーザー判読できる文字列変換します

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

解説解説

FormatFlags プロパティの値だけが変換されます。

使用例使用例

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

Public Sub ToStringExample(ByVal
 e As PaintEventArgs)
    Dim g As Graphics = e.Graphics
    Dim blueBrush As New
 SolidBrush(Color.FromArgb(255, 0, 0, 255))
    Dim myFont As New Font("Times
 New Roman", 14)
    Dim myStringFormat As New
 StringFormat

    ' String variable to hold the values of the StringFormat object.
    Dim strFmtString As String

    ' Convert the string format object to a string (only certain
    ' information in the object is converted) and display the string.
    strFmtString = myStringFormat.ToString()
    g.DrawString("Before changing properties:   ",
 myFont, blueBrush, _
    20, 40, myStringFormat)

    ' Change some properties of the string format.
    myStringFormat.Trimming = StringTrimming.None
    myStringFormat.FormatFlags = StringFormatFlags.NoWrap Or _
    StringFormatFlags.NoClip

    ' Convert the string format object to a string and display the
    ' string. The string will be different because the properties of
    ' the string format have changed.
    strFmtString = myStringFormat.ToString()
    g.DrawString("After changing properties:   ",
 myFont, blueBrush, _
    20, 70, myStringFormat)
End Sub
public void ToStringExample(PaintEventArgs
 e)
{
    Graphics     g = e.Graphics;
    SolidBrush   blueBrush = new SolidBrush(Color.FromArgb(255,
 0, 0, 255));
    Font         myFont = new Font("Times New Roman",
 14);
    StringFormat myStringFormat = new StringFormat();
             
    // String variable to hold the values of the StringFormat object.
    string    strFmtString;
             
    // Convert the string format object to a string (only certain information
    // in the object is converted) and display the string.
    strFmtString = myStringFormat.ToString();
    g.DrawString("Before changing properties:   " + myStringFormat,
        myFont, blueBrush, 20, 40);
             
    // Change some properties of the string format
    myStringFormat.Trimming = StringTrimming.None;
    myStringFormat.FormatFlags =   StringFormatFlags.NoWrap
        | StringFormatFlags.NoClip;
             
    // Convert the string format object to a string and display the
 string.
    // The string will be different because the properties of the string
    // format have changed.
    strFmtString = myStringFormat.ToString();
    g.DrawString("After changing properties:   " + myStringFormat,
        myFont, blueBrush, 20, 70);
}
void ToStringExample( PaintEventArgs^ e )
{
   Graphics^ g = e->Graphics;
   SolidBrush^ blueBrush = gcnew SolidBrush( Color::FromArgb( 255, 0, 0, 255 ) );
   System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Times New Roman",14
 );
   StringFormat^ myStringFormat = gcnew StringFormat;

   // String variable to hold the values of the StringFormat object.
   String^ strFmtString;

   // Convert the string format object to a string (only certain information
   // in the object is converted) and display the string.
   strFmtString = myStringFormat->ToString();
   g->DrawString( String::Format( "Before changing properties:   {0}",
 myStringFormat ), myFont, blueBrush, 20, 40 );

   // Change some properties of the string format
   myStringFormat->Trimming = StringTrimming::None;
   myStringFormat->FormatFlags = (StringFormatFlags)(StringFormatFlags::NoWrap
 | StringFormatFlags::NoClip);

   // Convert the string format object to a string and display the string.
   // The string will be different because the properties of the string
   // format have changed.
   strFmtString = myStringFormat->ToString();
   g->DrawString( String::Format( "After changing properties:   {0}",
 myStringFormat ), myFont, blueBrush, 20, 70 );
}
public void ToStringExample(PaintEventArgs
 e)
{
    Graphics g = e.get_Graphics();
    SolidBrush blueBrush = new SolidBrush(Color.FromArgb(255,
 0, 0, 255));
    Font myFont = new Font("Times New Roman", 14);
    StringFormat myStringFormat = new StringFormat();

    // String variable to hold the values of the StringFormat object.
    String strFmtString;

    // Convert the string format object to a string (only certain 
    // information in the object is converted) and display the string.
    strFmtString = myStringFormat.ToString();
    g.DrawString("Before changing properties:   " + myStringFormat, myFont
,
        blueBrush, 20, 40);

    // Change some properties of the string format
    myStringFormat.set_Trimming(StringTrimming.None);
    myStringFormat.set_FormatFlags(
        StringFormatFlags.NoWrap | StringFormatFlags.NoClip);

    // Convert the string format object to a string and display the
 string.
    // The string will be different because the properties of the string
    // format have changed.
    strFmtString = myStringFormat.ToString();
    g.DrawString("After changing properties:   " + myStringFormat, myFont
,
        blueBrush, 20, 70);
} //ToStringExample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からStringFormat.ToString メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からStringFormat.ToString メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からStringFormat.ToString メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

StringFormat.ToString メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



StringFormat.ToString メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS