StringFormat.SetDigitSubstitution Method
Specifies the language and method to be used when local digits are substituted for western digits.
Namespace: System.Drawing
Assembly: System.Drawing (in System.Drawing.dll)
Parameters
- language
- Type: System.Int32
A National Language Support (NLS) language identifier that identifies the language that will be used when local digits are substituted for western digits. You can pass the LCID property of a CultureInfo object as the NLS language identifier. For example, suppose you create a CultureInfo object by passing the string "ar-EG" to a CultureInfo constructor. If you pass the LCID property of that CultureInfo object along with Traditional to the SetDigitSubstitution method, then Arabic-Indic digits will be substituted for western digits at display time.
- substitute
- Type: System.Drawing.StringDigitSubstitute
An element of the StringDigitSubstitute enumeration that specifies how digits are displayed.
The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:
Sets, for the StringFormat, the language to be used and the substitution method to be used.
Draws the string.
Repeats the above two steps for two different languages (Arabic and Thai).
The National substitution method and Traditional substitution method are demonstrated for each of the two languages. 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 = 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); }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.