DataTableCollection.Item[] 속성

정의

컬렉션에서 지정한 DataTable 개체를 가져옵니다.

오버로드

Item[Int32]

지정된 인덱스의 DataTable 개체를 가져옵니다.

Item[String]

지정한 이름을 가진 DataTable 개체를 가져옵니다.

Item[String, String]

지정된 네임스페이스에서 지정된 이름을 가진 DataTable 개체를 가져옵니다.

Item[Int32]

Source:
DataTableCollection.cs
Source:
DataTableCollection.cs
Source:
DataTableCollection.cs

지정된 인덱스의 DataTable 개체를 가져옵니다.

public:
 property System::Data::DataTable ^ default[int] { System::Data::DataTable ^ get(int index); };
public System.Data.DataTable this[int index] { get; }
member this.Item(int) : System.Data.DataTable
Default Public ReadOnly Property Item(index As Integer) As DataTable

매개 변수

index
Int32

찾을 DataTable의 인덱스(0부터 시작)입니다.

속성 값

DataTable 지정된 인덱스가 있는 입니다. 그렇지 않으면 nullDataTable 입니다.

예외

인덱스 값이 컬렉션의 항목 수보다 큰 경우

예제

다음 예제에서는 인덱스로 를 DataTable 검색합니다.

private void GetDataTableByIndex()
{
   // presuming a DataGrid is displaying more than one table, get its DataSet.
   DataSet thisDataSet = (DataSet)DataGrid1.DataSource;
   // Get the DataTableCollection.
   DataTableCollection tablesCollection = thisDataSet.Tables;
   // Iterate through the collection to get each table name.
   for (int i = 0; i < tablesCollection.Count; i++)
      Console.WriteLine(tablesCollection[i].TableName);
}
Private Sub GetDataTableByIndex()
    ' Presuming a DataGrid is displaying more than one table, get its DataSet.
    Dim thisDataSet As DataSet = CType(DataGrid1.DataSource, DataSet)

    ' Get the DataTableCollection.
    Dim tablesCollection As DataTableCollection = thisDataSet.Tables

    ' Iterate through the collection to get each table name.
    Dim i As Integer
    For i = 0 To tablesCollection.Count - 1
       Console.WriteLine(tablesCollection(i).TableName)
    Next
End Sub

설명

메서드를 Contains 사용하여 특정 인덱스가 있는 테이블이 있는지 여부를 확인합니다.

테이블 이름이 있지만 해당 인덱스가 아닌 경우 메서드를 IndexOf 사용하여 인덱스 반환

추가 정보

적용 대상

Item[String]

Source:
DataTableCollection.cs
Source:
DataTableCollection.cs
Source:
DataTableCollection.cs

지정한 이름을 가진 DataTable 개체를 가져옵니다.

public:
 property System::Data::DataTable ^ default[System::String ^] { System::Data::DataTable ^ get(System::String ^ name); };
public System.Data.DataTable? this[string? name] { get; }
public System.Data.DataTable this[string name] { get; }
member this.Item(string) : System.Data.DataTable
Default Public ReadOnly Property Item(name As String) As DataTable

매개 변수

name
String

찾을 DataTable의 이름입니다.

속성 값

지정된 이름의 DataTable이거나, DataTable이 없으면 null입니다.

예제

다음 예제에서는 에서 이름으로 단일 테이블을 검색합니다 DataTableCollection.

private void GetTableByName()
{
    // Presuming a DataGrid is displaying more than one table, get its DataSet.
    DataSet thisDataSet = (DataSet)DataGrid1.DataSource;

    // Get the DataTableCollection.
    DataTableCollection tablesCollection = thisDataSet.Tables;

    // Get a specific table by name.
    DataTable table = tablesCollection["Suppliers"];
    Console.WriteLine(table.TableName);
}
Private Sub GetTableByName()
    ' Presuming a DataGrid is displaying more than one table, 
    ' get its DataSet.
    Dim thisDataSet As DataSet = CType(DataGrid1.DataSource, DataSet)

    ' Get the DataTableCollection.
    Dim tablesCollection As DataTableCollection = thisDataSet.Tables

    ' Get a specific table by name.
    Dim table As DataTable = tablesCollection("Suppliers")
    Console.WriteLine(table.TableName)
End Sub

설명

DataTable 검색 문자열의 경우와 일치하는 이름이 있으면 반환됩니다. 그렇지 않으면 대/소문자를 구분하지 않는 검색이 수행되고 이 검색과 일치하는 이름이 발견되면 DataTable 반환됩니다.

메서드를 Contains 사용하여 특정 이름 또는 인덱스가 있는 테이블이 있는지 여부를 확인합니다.

적용 대상

Item[String, String]

Source:
DataTableCollection.cs
Source:
DataTableCollection.cs
Source:
DataTableCollection.cs

지정된 네임스페이스에서 지정된 이름을 가진 DataTable 개체를 가져옵니다.

public:
 property System::Data::DataTable ^ default[System::String ^, System::String ^] { System::Data::DataTable ^ get(System::String ^ name, System::String ^ tableNamespace); };
public System.Data.DataTable? this[string? name, string tableNamespace] { get; }
public System.Data.DataTable this[string name, string tableNamespace] { get; }
member this.Item(string * string) : System.Data.DataTable
Default Public ReadOnly Property Item(name As String, tableNamespace As String) As DataTable

매개 변수

name
String

찾을 DataTable의 이름입니다.

tableNamespace
String

찾을 DataTable 네임스페이스의 이름입니다.

속성 값

지정된 이름의 DataTable이거나, DataTable이 없으면 null입니다.

적용 대상