CurrencyManager::List Property

 

Gets the list for this CurrencyManager.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public:
property IList^ List {
	IList^ get();
}

Property Value

Type: System.Collections::IList^

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

.NET Framework
Available since 1.1
Return to top
Show: