CurrencyManager.List Propriedade

Definição

Obtém a lista para isto 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

Valor de Propriedade

E IList que contém a lista.

Exemplos

O exemplo de código seguinte permite aos utilizadores editar um conjunto de registos, mas sem adicionar novos registos. No Navigate caso de um DataGrid controlo, o IList devolvido pela List propriedade é convertido numa DataView variável. A AllowNew propriedade do DataView é definida como 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

Observações

O objeto devolvido pela List propriedade pode ser lançado para qualquer tipo que implemente a IList interface. Isto será frequentemente usado quando souber o tipo da lista subjacente. Por exemplo, se estiver vinculado a um DataSet, a lista subjacente é um DataView (que implementa IList). Outras classes que implementam a interface (esta não é uma lista completa) incluem Array, ArrayList, e CollectionBase.

A forma como usas a List propriedade depende da classe que implementa a IList interface. Por exemplo, pode usar a List propriedade para determinar o nome da lista. Se a fonte de dados implementar a ITypedList interface, pode usar o GetListName método para devolver o nome da tabela atual. Isto é mostrado no código C# abaixo:

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));
}

Aplica-se a

Ver também