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

Definición

Especifica el idioma y el método que se utiliza cuando los dígitos locales se sustituyen por dígitos occidentales.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)

Parámetros

language
Int32 Int32 Int32 Int32

Un identificador de idioma NLS (compatibilidad con el idioma nacional) que identifica el idioma que se utilizará cuando los dígitos locales se sustituyan por dígitos occidentales.A National Language Support (NLS) language identifier that identifies the language that will be used when local digits are substituted for western digits. Se puede pasar la propiedad LCID de un objeto CultureInfo como el identificador de idioma NLS.You can pass the LCID property of a CultureInfo object as the NLS language identifier. Por ejemplo, supongamos que se crea un objeto CultureInfo pasando la cadena "ar-EG" a un constructor CultureInfo.For example, suppose you create a CultureInfo object by passing the string "ar-EG" to a CultureInfo constructor. Si se pasa la propiedad LCID de este objeto CultureInfo junto con Traditional al método SetDigitSubstitution(Int32, StringDigitSubstitute), los dígitos árabo-índicos se sustituirán por dígitos occidentales en el momento de la presentación.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

Elemento de la enumeración StringDigitSubstitute que especifica cómo se muestran los dígitos.An element of the StringDigitSubstitute enumeration that specifies how digits are displayed.

Ejemplos

El ejemplo siguiente está diseñado para su uso con Windows Forms y requiere PaintEventArgs e, que es un parámetro de la Paint controlador de eventos.The following example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. El código realiza las siguientes acciones:The code performs the following actions:

  • Los conjuntos, para el StringFormat, el idioma que se usará y el método de sustitución que se usará.Sets, for the StringFormat, the language to be used and the substitution method to be used.

  • Dibuja la cadena.Draws the string.

  • Repite los dos pasos anteriores para dos idiomas distintos (árabe y tailandés).Repeats the above two steps for two different languages (Arabic and Thai).

El método de sustitución nacional y el método de sustitución tradicional se muestran para cada uno de los dos lenguajes.The National substitution method and Traditional substitution method are demonstrated for each of the two languages. El método nacional muestra los dígitos según el idioma nacional oficial de la configuración regional del usuario.The National method displays digits according to the official national language of the user's locale. El método tradicional muestra dígitos según script nativo del usuario o el idioma, que puede ser diferente del idioma nacional oficial.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

Se aplica a