英語で読む

次の方法で共有


DataColumn.Caption プロパティ

定義

列のキャプションを取得または設定します。

C#
public string Caption { get; set; }
C#
[System.Data.DataSysDescription("DataColumnCaptionDescr")]
public string Caption { get; set; }

プロパティ値

列のキャプション。 キャプションが設定されていない場合は、ColumnName 値を返します。

属性

次の例では、新 DataTableしい を作成します。 次に、 に 3 つのDataColumnオブジェクトをDataColumnCollection追加し、各 DataColumnの プロパティをCaption設定します。

C#
private void CreateDataTable()
{
   DataTable table;
   DataColumn column;

   table = new DataTable("Customers");

   //CustomerID column
   column = table.Columns.Add("CustomerID",
       System.Type.GetType("System.Int32"));
   column.Unique = true;
    
   //CustomerName column
   column = table.Columns.Add("CustomerName",
       System.Type.GetType("System.String"));
   column.Caption = "Name";

   //CreditLimit
   column = table.Columns.Add("CreditLimit",
       System.Type.GetType("System.Double"));
   column.DefaultValue = 0;
   column.Caption = "Limit";

   table.Rows.Add(new object[] {1, "Jonathan", 23.44});
   table.Rows.Add(new object[] {2, "Bill", 56.87});
}

注釈

プロパティを使用して、 の Caption わかりやすい名前またはフレンドリ名を DataColumn表示できます。

適用対象

製品 バージョン
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

こちらもご覧ください