Habanero.Faces.Win.ListViewCollectionManager.SetCollection C# (CSharp) Method

SetCollection() public method

Specify the collection of objects to display and add these to the ListView object
public SetCollection ( IBusinessObjectCollection collection ) : void
collection IBusinessObjectCollection The collection of business objects
return void
        public void SetCollection(IBusinessObjectCollection collection)
        {

            if (Collection != null)
            {
                Collection.BusinessObjectAdded -= BusinessObjectAddedHandler;
                Collection.BusinessObjectRemoved -= BusinessObjectRemovedHandler;
                Collection.BusinessObjectUpdated -= BusinessObjectUpdatedHandler;
            }
            Collection = collection;
            SetListViewCollection(ListView, Collection);
            Collection.BusinessObjectAdded += BusinessObjectAddedHandler;
            Collection.BusinessObjectRemoved += BusinessObjectRemovedHandler;
            Collection.BusinessObjectUpdated += BusinessObjectUpdatedHandler;
        }

Usage Example

 public void TestGetBusinessObject()
 {
     ListView listView = CreateListView();
     ListViewCollectionManager controller = new ListViewCollectionManager(listView);
     BusinessObjectCollection<MyBO> col = GetColWith3Items();
     controller.SetCollection(col);
     //---------------Assert Precondition----------------
     Assert.AreEqual(3, listView.Items.Count);
     //---------------Execute Test ----------------------
     listView.Items[2].Selected = true;
     listView.Items[0].Focused = true;
     //---------------Test Result -----------------------
     Assert.AreEqual(1, listView.SelectedItems.Count);
     Assert.IsNotNull(controller.SelectedBusinessObject);
     Assert.AreSame(col[2], controller.SelectedBusinessObject);
 }
All Usage Examples Of Habanero.Faces.Win.ListViewCollectionManager::SetCollection