DataTableCollection.Item[] 속성

정의

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

오버로드

Name Description
Item[Int32]

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

Item[String]

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

Item[String, String]

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

Item[Int32]

지정된 인덱스에서 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

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

속성 값

지정된 인덱스가 있는 A DataTable 입니다. 그렇지 않으면 null 인덱스가 DataTable 없습니다.

예외

인덱스 값이 컬렉션의 항목 수보다 큽니다.

예제

다음 예제에서는 인덱스별로 검색합니다 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]

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

public:
 property System::Data::DataTable ^ default[System::String ^] { System::Data::DataTable ^ get(System::String ^ name); };
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 입니다.

속성 값

지정된 이름의 A DataTable 입니다. 그렇지 않으면 nullDataTable 해당 이름이 없습니다.

예제

다음 예제에서는 .에서 이름으로 단일 테이블을 검색합니다 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]

지정된 네임스페이 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; }
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 스의 이름입니다.

속성 값

지정된 이름의 A DataTable 입니다. 그렇지 않으면 nullDataTable 해당 이름이 없습니다.

적용 대상