DataColumn.Caption 属性
获取或设置列的标题。
**命名空间:**System.Data
**程序集:**System.Data(在 system.data.dll 中)
语法
声明
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);
}
/** @property */
public String get_Caption ()
/** @property */
public void set_Caption (String value)
public function get Caption () : String
public function set Caption (value : String)
属性值
列的标题。如果没有设置,则返回 ColumnName 的值。
备注
可使用 Caption 属性来显示 DataColumn 的描述性名称或友好名称。
示例
下面的示例创建新的 DataTable。它然后向 DataColumnCollection 添加三个 DataColumn 对象并为每个 DataColumn 设置 Caption 属性。
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 98、Windows 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
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:2.0、1.0