Registering Business Objects with a Windows Form

When you use a business object in an MM .NET business form (mmBusinessForm or one of its derived classes), you should register the business object with the form by calling the form's RegisterBizObj or RegisterPrimaryBizObj method, passing a reference to the business object. This registration process allows the business object to be referenced by the form and by other controls (For more information, see the Help topic Understanding Primary Business Objects).

For example, in the following form's constructor method, a business object is instantiated and registered with the form using the RegisterPrimaryBizObj method:

In C#:

using OakLeaf.MM.Windows.Forms;
using MyCompany.MyProduct.Business;	// Specify your business object namespace here!!!

public class CustomerForm : mmBusinessForm
{
	Customer oCustomer;

	public CustomerForm()
	{
		this.oCustomer = (Customer)this.RegisterPrimaryBizObj(new Customer());

		//
		// Required for Windows Form Designer support
		// 
		InitializeComponent();
	}
}

In VB .NET:

Imports OakLeaf.MM.Windows.Forms
Imports MyCompany.MyProduct.Business	  ' Specify your business object namespace here!!!

Public Class CustomerForm
	Inherits mmBusinessForm
   
	Dim oCustomer As Customer

	Public Sub New()
      		Me.oCustomer = CType(Me.RegisterPrimaryBizObj(New Customer()), Customer)
      
      		'
      		' Required for Windows Form Designer support
      		' 
      		InitializeComponent()
   	End Sub 'New
End Class


Note: The registration code is placed before the call to InitializeComponent. This ensures the business object is available before any bound controls are instantiated.


The RegisterBizObj and RegisterPrimaryBizObj methods return a reference to the registered business object. This is convenient if you need to get a reference to a newly instantiated and registered business object as shown in the code sample above.


© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 04/16/17
Comment or report problem with topic