DataGridTextBoxColumn.FormatInfo DataGridTextBoxColumn.FormatInfo DataGridTextBoxColumn.FormatInfo DataGridTextBoxColumn.FormatInfo Property

定義

値の書式指定方法を決定するために使用する、カルチャ固有の情報を取得または設定します。Gets or sets the culture specific information used to determine how values are formatted.

public:
 property IFormatProvider ^ FormatInfo { IFormatProvider ^ get(); void set(IFormatProvider ^ value); };
[System.ComponentModel.Browsable(false)]
public IFormatProvider FormatInfo { get; set; }
member this.FormatInfo : IFormatProvider with get, set
Public Property FormatInfo As IFormatProvider

プロパティ値

IFormatProvider インターフェイスを実装する CultureInfo クラスなどのオブジェクト。An object that implements the IFormatProvider interface, such as the CultureInfo class.

次の例では、 CultureInfo新しいオブジェクトを作成し、 FormatInfo DataGridTextBoxColumnオブジェクトのプロパティに割り当てます。The following example creates a new CultureInfo object and assigns it to the FormatInfo property of a DataGridTextBoxColumn object. また、この例でFormatは、プロパティを "c" に設定して、列の値を通貨として表示するように指定しています。The example also sets the Format property to "c" to specify that the column should display values as currency.

private:
   void ChangeColumnCultureInfo()
   {
      /* Create a new CultureInfo Object* using the
        the locale ID for Italy. */
      System::Globalization::CultureInfo^ ItalyCultureInfo = gcnew CultureInfo( 0x0410 );
      
      /* Cast a column that holds numeric values to the
        DataGridTextBoxColumn type, and set the FormatInfo
        property to the new CultureInfo Object*. */
      DataGridTextBoxColumn^ myGridTextBoxColumn =
         dynamic_cast<DataGridTextBoxColumn^>(myDataGrid->TableStyles[ "Orders" ]->
         GridColumnStyles[ "OrderAmount" ]);
      myGridTextBoxColumn->FormatInfo = ItalyCultureInfo;
      myGridTextBoxColumn->Format = "c";
   }
private void ChangeColumnCultureInfo(){
   /* Create a new CultureInfo object using the 
   the locale ID for Italy. */
   System.Globalization.CultureInfo ItalyCultureInfo= 
   new CultureInfo(0x0410);
     
   /* Cast a column that holds numeric values to the   
   DataGridTextBoxColumn type, and set the FormatInfo
   property to the new CultureInfo object. */
   DataGridTextBoxColumn myGridTextBoxColumn = 
   (DataGridTextBoxColumn) myDataGrid.TableStyles["Orders"].
   GridColumnStyles["OrderAmount"];
   myGridTextBoxColumn.FormatInfo = ItalyCultureInfo;
   myGridTextBoxColumn.Format = "c";
}
Public Class Form1:Inherits Form
private myDataGrid as DataGrid    
    Public Shared Sub Main()
        Dim t As New Form1()
        ' Write a purchase order.
    End Sub
Private Sub ChangeColumnCultureInfo()
   ' Create a new CultureInfo object using the 
   ' the locale ID for Italy. 
   Dim ItalyCultureInfo As CultureInfo = New _
   CultureInfo(&H0410)
   ' Cast a column that holds numeric values to the   
   ' DataGridTextBoxColumn type, and set the FormatInfo
   ' property to the new CultureInfo object. 
   Dim myGridTextBoxColumn As DataGridTextBoxColumn = _
   CType( myDataGrid.TableStyles("Orders"). _
   GridColumnStyles("OrderAmount"), DataGridTextBoxColumn)
   myGridTextBoxColumn.FormatInfo = ItalyCultureInfo
   myGridTextBoxColumn.Format = "c"
End Sub

注釈

Formatプロパティをいずれかの書式設定文字に設定するとDataGridTextBoxColumn 、はFormatInfoプロパティによって提供される情報を使用して、使用するカルチャに固有の書式をさらに指定します。When setting the Format property to one of the formatting characters, the DataGridTextBoxColumn uses the information provided by the FormatInfo property to further specify what cultural-specific formatting to use. たとえば、 Formatプロパティが書式文字 "c" (通貨の場合) に設定されている場合は、さらに、リラのシンボルを使用するように指定できます。For example, when the Format property is set to the format character "c" (for currency), you can further specify that the symbol for the lira be used. これを行うには、イタリアCultureInfo語のロケール ID を使用して新しいオブジェクトをFormatInfo作成し、プロパティCultureInfoを新しいオブジェクトに設定します。To do this, create a new CultureInfo object with the locale ID for Italy, and set the FormatInfo property to the new CultureInfo object.

文字の書式設定の詳細については、「型の書式設定」および「カスタム日時書式指定文字列」を参照してください。For more information about formatting characters, see Formatting Types and Custom Date and Time Format Strings.

適用対象

こちらもご覧ください