DataColumn.Caption プロパティ
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
列のキャプションを取得または設定します。
public:
property System::String ^ Caption { System::String ^ get(); void set(System::String ^ value); };
C#
public string Caption { get; set; }
C#
[System.Data.DataSysDescription("DataColumnCaptionDescr")]
public string Caption { get; set; }
member this.Caption : string with get, set
[<System.Data.DataSysDescription("DataColumnCaptionDescr")>]
member this.Caption : string with get, set
Public Property Caption As String
列のキャプション。 キャプションが設定されていない場合は、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});
}
Private Sub CreateDataTable()
Dim table As DataTable
Dim column As DataColumn
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})
End Sub
プロパティを使用して、 の 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 |
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。