Gets or sets the caption for the column.
Public Property Caption As String
Dim instance As DataColumn Dim value As String value = instance.Caption instance.Caption = value
public string Caption { get; set; }
public: property String^ Caption { String^ get (); void set (String^ value); }
public function get Caption () : String public function set Caption (value : String)
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
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}); }
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune