CurrencyManager.List 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
이 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 목록이 들어 있는 항목입니다.
예제
다음 코드 예제에서는 사용자가 레코드 집합을 편집할 수 있지만 새 레코드를 추가하지는 않습니다. 컨트롤의 NavigateDataGrid 경우 속성에서 IList 반환된 List 변수로 DataView 캐스팅됩니다.
AllowNew의 DataView 속성은 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경우 기본 목록은 (구현)입니다 DataViewIList. 인터페이스를 구현하는 다른 클래스(전체 목록이 아님)에는 Array, ArrayList및 CollectionBase.
이 속성을 사용하는 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));
}