Export (0) Print
Expand All

DataColumn.Caption Property

Gets or sets the caption for the column.

Namespace: System.Data
Assembly: System.Data (in system.data.dll)

'Declaration
Public Property Caption As String
'Usage
Dim instance As DataColumn
Dim value As String

value = instance.Caption

instance.Caption = value
/** @property */
public String get_Caption ()

/** @property */
public void set_Caption (String value)

public function get Caption () : String

public function set Caption (value : String)

Not applicable.

Property Value

The caption of the column. If not set, returns the ColumnName value.

You can use the Caption property to display a descriptive or friendly name for a DataColumn.

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 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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2014 Microsoft