Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CurrencyManager.List Property

Gets the list for this CurrencyManager.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public IList List { get; }
/** @property */
public IList get_List ()

public function get List () : IList

Property Value

An IList that contains the list.

The object returned by the List property can be cast to any type that implements the IList interface. This will be commonly used when you know the type of the underlying list. For example, if you are data-bound to a DataSet, the underlying list is a DataView (which implements IList). Other classes that implement the interface (this is not a complete list) include Array, ArrayList, and CollectionBase.

How you use the List property depends on the class that implements the IList interface. For example, you can use the List property to determine the name of the list. If the data source implements the ITypedList interface, you can use the GetListName method to return the name of the current table. This is shown in the C# code below:

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

The following code example allows users to edit a set of records, but not add any new ones. In the Navigate event of a DataGrid control, the IList returned by the List property is cast to a DataView variable. The AllowNew property of the DataView is set to 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 void GridNavigate(Object sender, NavigateEventArgs e)
{
    if (e.get_Forward()) {
        DataSet ds = (DataSet)grid.get_DataSource();
        CurrencyManager cm = (CurrencyManager)get_BindingContext().
            get_Item(ds, "Customers.CustOrders");

        // Cast the IList to a DataView to set the AllowNew property.
        DataView dv = (DataView)(cm.get_List());
        dv.set_AllowNew(false);
    }
} //GridNavigate

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft