StringFormat.SetDigitSubstitution(Int32, StringDigitSubstitute) StringFormat.SetDigitSubstitution(Int32, StringDigitSubstitute) StringFormat.SetDigitSubstitution(Int32, StringDigitSubstitute) StringFormat.SetDigitSubstitution(Int32, StringDigitSubstitute) Method

定義

西ヨーロッパ言語の数字をローカルの数字に置換する際に使用される言語と方法を指定します。Specifies the language and method to be used when local digits are substituted for western digits.

public:
 void SetDigitSubstitution(int language, System::Drawing::StringDigitSubstitute substitute);
public void SetDigitSubstitution (int language, System.Drawing.StringDigitSubstitute substitute);
member this.SetDigitSubstitution : int * System.Drawing.StringDigitSubstitute -> unit
Public Sub SetDigitSubstitution (language As Integer, substitute As StringDigitSubstitute)

パラメーター

language
Int32 Int32 Int32 Int32

西ヨーロッパ言語の数字をローカルの数字に置換する際に使用される言語を特定する NLS (National Language Support) 言語の ID。A National Language Support (NLS) language identifier that identifies the language that will be used when local digits are substituted for western digits. CultureInfo オブジェクトの LCID プロパティを NLS 言語の ID として渡すことができます。You can pass the LCID property of a CultureInfo object as the NLS language identifier. たとえば、文字列 "ar-EG" を CultureInfo コンストラクターに渡して、CultureInfo オブジェクトを作成する場合を想定します。For example, suppose you create a CultureInfo object by passing the string "ar-EG" to a CultureInfo constructor. その CultureInfo オブジェクトの LCID プロパティを Traditional と共に SetDigitSubstitution(Int32, StringDigitSubstitute) メソッドに渡すと、表示には西ヨーロッパ言語の数字の代わりにアラビア インド数字が使用されます。If you pass the LCID property of that CultureInfo object along with Traditional to the SetDigitSubstitution(Int32, StringDigitSubstitute) method, then Arabic-Indic digits will be substituted for western digits at display time.

substitute
StringDigitSubstitute StringDigitSubstitute StringDigitSubstitute StringDigitSubstitute

数字の表示方法を指定する StringDigitSubstitute 列挙体の要素。An element of the StringDigitSubstitute enumeration that specifies how digits are displayed.

次の例は、Windows フォームで使用するために設計されています。 また必要がPaintEventArgs e、はのパラメーター、Paintイベント ハンドラー。The following 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:

  • セットのStringFormat、使用する言語、代替メソッドを使用します。Sets, for the StringFormat, the language to be used and the substitution method to be used.

  • 文字列を描画します。Draws the string.

  • 2 つの異なる言語 (アラビア語、タイ語) には、上記の 2 つの手順を繰り返します。Repeats the above two steps for two different languages (Arabic and Thai).

国別置換メソッドと従来の置換方法については、2 つの言語ごとに説明します。The National substitution method and Traditional substitution method are demonstrated for each of the two languages. National メソッドでは、ユーザーのロケールの公用語に従って桁の数字が表示されます。The National method displays digits according to the official national language of the user's locale. 従来の方法では、ユーザーのネイティブ スクリプトまたは公用語とは異なる場合があります言語に従って桁を表示します。The Traditional method displays digits according to the user's native script or language, which may be different from the official national language.

public:
   void SetDigitSubExample( PaintEventArgs^ e )
   {
      Graphics^ g = e->Graphics;
      SolidBrush^ blueBrush = gcnew SolidBrush( Color::FromArgb( 255, 0, 0, 255 ) );
      System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Courier New",12 );
      StringFormat^ myStringFormat = gcnew StringFormat;
      String^ myString = "0 1 2 3 4 5 6 7 8 9";

      // Arabic (0x0C01) digits.
      // Use National substitution method.
      myStringFormat->SetDigitSubstitution( 0x0C01, StringDigitSubstitute::National );
      g->DrawString( String::Format( "Arabic:\nMethod of substitution = National:     {0}", myString ), myFont, blueBrush, PointF(10.0f,20.0f), myStringFormat );

      // Use Traditional substitution method.
      myStringFormat->SetDigitSubstitution( 0x0C01, StringDigitSubstitute::Traditional );
      g->DrawString( String::Format( "Method of substitution = Traditional:  {0}", myString ), myFont, blueBrush, PointF(10.0f,55.0f), myStringFormat );

      // Thai (0x041E) digits.
      // Use National substitution method.
      myStringFormat->SetDigitSubstitution( 0x041E, StringDigitSubstitute::National );
      g->DrawString( String::Format( "Thai:\nMethod of substitution = National:     {0}", myString ), myFont, blueBrush, PointF(10.0f,85.0f), myStringFormat );

      // Use Traditional substitution method.
      myStringFormat->SetDigitSubstitution( 0x041E, StringDigitSubstitute::Traditional );
      g->DrawString( String::Format( "Method of substitution = Traditional:  {0}", myString ), myFont, blueBrush, PointF(10.0f,120.0f), myStringFormat );
   }
public void SetDigitSubExample(PaintEventArgs e)
{
    Graphics     g = e.Graphics;
    SolidBrush   blueBrush = new SolidBrush(Color.FromArgb(255, 0, 0, 255));
    Font         myFont = new Font("Courier New", 12);
    StringFormat myStringFormat = new StringFormat();
    string       myString = "0 1 2 3 4 5 6 7 8 9";
             
       
    // Arabic (0x0C01) digits.
             
    // Use National substitution method.
    myStringFormat.SetDigitSubstitution(0x0C01,
        StringDigitSubstitute.National);
    g.DrawString(
        "Arabic:\nMethod of substitution = National:     " + myString,
        myFont, blueBrush, new PointF(10.0f, 20.0f), myStringFormat);
             
    // Use Traditional substitution method.
    myStringFormat.SetDigitSubstitution(0x0C01,
        StringDigitSubstitute.Traditional);
    g.DrawString(
        "Method of substitution = Traditional:  " + myString,
        myFont, blueBrush, new PointF(10.0f, 55.0f), myStringFormat);
             
    // Thai (0x041E) digits.
   
    // Use National substitution method.
    myStringFormat.SetDigitSubstitution(0x041E,
        StringDigitSubstitute.National);
    g.DrawString(
        "Thai:\nMethod of substitution = National:     " + myString,
        myFont, blueBrush, new PointF(10.0f, 85.0f), myStringFormat);
             
    // Use Traditional substitution method.
    myStringFormat.SetDigitSubstitution(0x041E,
        StringDigitSubstitute.Traditional);
    g.DrawString(
        "Method of substitution = Traditional:  " + myString,
        myFont, blueBrush, new PointF(10.0f, 120.0f), myStringFormat);
}
Public Sub SetDigitSubExample(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("Courier New", 12)
    Dim myStringFormat As New StringFormat
    Dim myString As String = "0 1 2 3 4 5 6 7 8 9"

    ' Arabic (0x0C01) digits.

    ' Use National substitution method.
    myStringFormat.SetDigitSubstitution(&HC01, _
    StringDigitSubstitute.National)
    g.DrawString("Arabic:" & ControlChars.Cr & _
    "Method of substitution = National:     " & myString, _
    myFont, blueBrush, New PointF(10.0F, 20.0F), myStringFormat)

    ' Use Traditional substitution method.
    myStringFormat.SetDigitSubstitution(&HC01, _
    StringDigitSubstitute.Traditional)
    g.DrawString("Method of substitution = Traditional:  " _
    & myString, myFont, blueBrush, New PointF(10.0F, 55.0F), _
    myStringFormat)

    ' Thai (0x041E) digits.

    ' Use National substitution method.
    myStringFormat.SetDigitSubstitution(&H41E, _
    StringDigitSubstitute.National)
    g.DrawString("Thai:" & ControlChars.Cr & _
    "Method of substitution = National:     " & myString, _
    myFont, blueBrush, New PointF(10.0F, 85.0F), myStringFormat)

    ' Use Traditional substitution method.
    myStringFormat.SetDigitSubstitution(&H41E, _
    StringDigitSubstitute.Traditional)
    g.DrawString("Method of substitution = Traditional:  " _
    & myString, myFont, blueBrush, New PointF(10.0F, 120.0F), _
    myStringFormat)
End Sub

適用対象