DataColumn.ColumnName プロパティ


DataColumnCollection 内の列名を取得または設定します。Gets or sets the name of the column in the DataColumnCollection.

 property System::String ^ ColumnName { System::String ^ get(); void set(System::String ^ value); };
public string ColumnName { get; set; }
public string ColumnName { get; set; }
member this.ColumnName : string with get, set
Public Property ColumnName As String


列の名前。The name of the column.



このプロパティは null または空の文字列に設定され、列がコレクションに属しています。The property is set to null or an empty string and the column belongs to a collection.

同じ名前の列がコレクション内に既に存在します。A column with the same name already exists in the collection. 名前の比較では、大文字と小文字が区別されません。The name comparison is not case sensitive.

次の例では、DataSet内のすべてのテーブルのすべての列の ColumnName を取得します。The following examples gets the ColumnName for every column in every table in a DataSet. この例では、新しい ColumnNameDataColumn を作成する方法も示しています。The example also shows how to create a DataColumn with a new ColumnName.

   private void PrintColumnNames(DataSet dataSet)
       // For each DataTable, print the ColumnName.
       foreach(DataTable table in dataSet.Tables)
           foreach(DataColumn column in table.Columns)

   private void AddColumn(DataTable table)
       DataColumn column;
       column = new DataColumn();
       column.ColumnName = "SupplierID";
       column.DataType = System.Type.GetType("System.String");
       column.Unique = true;
       column.AutoIncrement = false;
       column.Caption = "SupplierID";
       column.ReadOnly = false;

       // Add the column to the table's columns collection.
Private Sub PrintColumnNames(dataSet As DataSet)
    Dim table As DataTable
    Dim column As DataColumn 

    ' For each DataTable, print the ColumnName.
    For Each table in dataSet.Tables
        For Each column in table.Columns
End Sub

Private Sub AddColumn(table As DataTable)
    Dim column As DataColumn
    column = New DataColumn()

    With column
        .ColumnName = "SupplierID"
        .DataType = System.Type.GetType("System.String")
        .Unique = True
        .AutoIncrement = False
        .Caption = "SupplierID"
        .ReadOnly = False
    End With

    ' Add the column to the table's columns collection.
End Sub


DataColumn が作成されると、ColumnName 値はありません。When a DataColumn is created, it has no ColumnName value. ただし、DataColumnDataTable オブジェクトの DataColumnCollection に追加されると、既定の名前 ("Column1"、"Column2" など) が与えられます。However, when the DataColumn is added to a DataColumnCollection for a DataTable object, it is given a default name ("Column1", "Column2", and so on).

既定では、Caption の値は ColumnName 値に設定されます。By default, the Caption value is set to the ColumnName value.