StrataFrame Forum

Implementing MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl

http://forum.strataframe.net/Topic2254.aspx

By Daniel Essin - 8/17/2006

I've got an existing form that I need to add MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl support, that is:

public partial class SearchForm : Form, IFormHelper, MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl



What methods do I need to add to make the "does not implement interface member" errors go away.
By StrataFrame Team - 8/17/2006

If you hover over the interface name on the inherits declaration, you should be the little "block" at the bottom, right-hand corner of the interface name.  When you put your mouse over the block, you'll get a menu that you can open up.  That menu should have an option that says "Implement Interface Explicitly," which will create the necessary member stubs for you.

The best way to make sure you implement it properly is to open up the BaseForm.vb file and use the implementation from that file.

By StrataFrame Team - 8/17/2006

The code for adding the IContainerControl interface to your existing form is this:

#region IContainerControl Members

private MicroFour.StrataFrame.Business.BusinessObjectCollection _BusinessObjects = new MicroFour.StrataFrame.Business.BusinessObjectCollection();
private List<MicroFour.StrataFrame.UI.IInitOnFormLoad> _ObjectsToInitOnLoad = new List<MicroFour.StrataFrame.UI.IInitOnFormLoad>();
private List<MicroFour.StrataFrame.UI.IPreInitOnFormLoad> _ObjectsToPreInitOnLoad = new List<MicroFour.StrataFrame.UI.IPreInitOnFormLoad>();

void MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl.AddBusinessObject(MicroFour.StrataFrame.Business.BusinessLayerBase BusinessObject)
{
this._BusinessObjects.Add(BusinessObject);
}

void MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl.AddObjectToInitOnLoad(MicroFour.StrataFrame.UI.IInitOnFormLoad ObjectToInit)
{
this._ObjectsToInitOnLoad.Add(ObjectToInit);
}

void MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl.AddObjectToPreInitOnLoad(MicroFour.StrataFrame.UI.IPreInitOnFormLoad ObjectToPreInit)
{
this._ObjectsToPreInitOnLoad.Add(ObjectToPreInit);
}

void MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl.RemoveBusinessObject(MicroFour.StrataFrame.Business.BusinessLayerBase BusinessObject)
{
this._BusinessObjects.Remove(BusinessObject);
}

#endregion

By StrataFrame Team - 8/17/2006

That code will not add the functionality for the business objects to initialize themselves when the form loads, but it will add them to the form's business objects collection.