CurrencyManager.List 속성

정의

CurrencyManager의 목록을 가져옵니다.

public:
 property System::Collections::IList ^ List { System::Collections::IList ^ get(); };
public System.Collections.IList List { get; }
member this.List : System.Collections.IList
Public ReadOnly Property List As IList

속성 값

목록이 들어 있는 IList입니다.

예제

다음 코드 예제에서는 사용자가 레코드 집합을 편집할 수 있지만 새 레코드를 추가하지는 않습니다. Navigate 의 경우는 DataGrid 컨트롤에서 IList 반환 되는 List 속성 변수로 DataView 캐스팅 합니다. DataViewAllowNew 속성이 false로 설정됩니다.

private:
   void Grid_Navigate( Object^ /*sender*/, NavigateEventArgs^ e )
   {
      if ( e->Forward )
      {
         DataSet^ ds = dynamic_cast<DataSet^>(grid->DataSource);
         CurrencyManager^ cm = dynamic_cast<CurrencyManager^>(BindingContext[ds, "Customers::CustOrders"]);
         
         // Cast the IList* to a DataView to set the AllowNew property.
         DataView^ dv = dynamic_cast<DataView^>(cm->List);
         dv->AllowNew = false;
      }
   }
private void Grid_Navigate(object sender, NavigateEventArgs e){
   if (e.Forward ){
      DataSet ds = (DataSet) grid.DataSource;
      CurrencyManager cm  = 
      (CurrencyManager)BindingContext[ds,"Customers.CustOrders"];
      // Cast the IList to a DataView to set the AllowNew property.
      DataView dv  = (DataView) cm.List;
      dv.AllowNew = false;
   }
}
Private Sub Grid_Navigate(sender As Object, e As NavigateEventArgs)
   If e.Forward Then
      Dim ds As DataSet = CType(grid.DataSource, DataSet)
      Dim cm As CurrencyManager = _
      CType(BindingContext(ds,"Customers.CustOrders"), CurrencyManager)
      ' Cast the IList to a DataView to set the AllowNew property.
      Dim dv As DataView = CType(cm.List, DataView)
      dv.AllowNew = false
   End If
End Sub

설명

반환 되는 개체를 List 속성 인터페이스를 구현 하는 모든 형식으로 IList 캐스팅할 수 있습니다. 이는 기본 목록의 형식을 알고 있을 때 일반적으로 사용됩니다. 예를 들어 데이터에 바인딩된 DataSet경우 기본 목록은 (를 구현하는IList)입니다 DataView . 인터페이스를 구현하는 다른 클래스(전체 목록은 아님)에는 , ArrayListCollectionBase가 포함Array됩니다.

사용 하는 방법 속성 List 은 인터페이스를 구현 하는 클래스에 IList 따라 달라 줍니다. 예를 들어 속성을 사용하여 List 목록의 이름을 확인할 수 있습니다. 데이터 원본이 인터페이스를 구현하는 ITypedList 경우 메서드를 GetListName 사용하여 현재 테이블의 이름을 반환할 수 있습니다. 아래 C# 코드에 나와 있습니다.

private void PrintCurrentListName(DataGrid myDataGrid){   
   CurrencyManager myCM = (CurrencyManager)   
   BindingContext[myDataGrid.DataSource, myDataGrid.DataMember];   
   IList myList = myCM.List;   
   ITypedList thisList = (ITypedList) myList;   
   Console.WriteLine(thisList.GetListName(null));   
}  

적용 대상

추가 정보