If I understand you correctly, you want to programatically add your user control (that contains a listview) to a form, then setup the listview to use data from a BO on the form. Assuming this is what you want to do, you have a few options:
- Expose the listview as a readonly property of the user control so you can setup it up in code. I.e. you'd use client code (the code in your form) something like:
UserControl _uc = new UserControl();
//Setup list population settings..
_uc.List.PopulationDataSourceSettings.MethodToExecute = "CopyDataFrom;BusinessLayer,BusinessCloneDataType";
// Add handler for list population (populateList would be the method on the form
// that handles this event)
_uc.List.ListPopulating += new ListPopulatingEventHandler(this.populateList);
- If you are always going to populate the list view from an external BO using CopyDataFrom, you'd be better off to just setup the listview in the user control that way, and add a BO property to your user control of type BusinessLayer. You'd then handle the ListPopulating event within the user control. The client code would then become:
UserControl _uc = new UserControl();
// Set BO
_uc.BusinessObject = this.MyLocalBO; //MyLocalBO being the one you want to load from
The code may not be entirely accurate, I just typed it in, but hopefully it gives you an idea of what you might want to do.