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 。
例
次のコード例では、ユーザーはレコードのセットを編集できますが、新しいレコードを追加することはできません。
DataGrid コントロールのNavigate イベントでは、List プロパティによって返されるIListが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にバインドされている場合、基になるリストは DataView です ( IListを実装します)。 インターフェイスを実装するその他のクラス (完全な一覧ではありません) には、 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));
}