DataColumn.Caption Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the caption for the column.
public:
property System::String ^ Caption { System::String ^ get(); void set(System::String ^ value); };
public string Caption { get; set; }
[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
Property Value
The caption of the column. If not set, returns the ColumnName value.
- Attributes
Examples
The following example creates a new DataTable. It then adds three DataColumn objects to a DataColumnCollection and sets the Caption property for each DataColumn.
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
Remarks
You can use the Caption property to display a descriptive or friendly name for a DataColumn.
Applies to
See also
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET