Using Specialized Buttons

MM .NET contains several Windows Forms buttons that possess specialized behavior and work in conjunction with associated business objects.

mmButtonCancel

This button class cancels all pending changes in the associated business object.

mmButtonDelete

This button class deletes the current record in the associated business object. The result of the Delete operation is stored in the button's Result property which is of type Boolean. If the delete was successful, Result is set to true, otherwise it's set to false.

mmButtonNew

This button class adds a new row to the associated business object. The result of the New operation is stored in the button's Result property which is of type Boolean. If the New operation was successful, Result is set to true, otherwise, it's set to false.

Typically, after adding a new row you want to display it in the user interface. To accomplish this, you need to tell the form's BindingContext object to position to the new row. For example:

In C#:

this.BindingContext[this.oOrder.GetCurrentDataSet(), "Orders"].Position = 
				this.oOrder.GetCurrentDataSet().Tables["Orders"].Rows.Count -1;

And in VB .NET:

Me.BindingContext(Me.oOrder.GetCurrentDataSet(), "Orders").Position = Me.oOrder.GetCurrentDataSet().Tables("Orders").Rows.Count - 1

This code passes a reference to a business object's DataSet, and DataTable name, and sets the position to the last row in the DataSet (Rows.Count -1) within the BindingContext object.

mmButtonSave

This button class saves pending changes in the associated business object. The result of the Save operation is stored in the button's Result property which is of enumeration type mmSaveDataResult. Possible values in this enumeration are:

  • RulesBroken
  • RulesPassed
  • RuleWarnings
  • SaveCanceled
  • Exception

If mmButtonSave.CloseOnSave is set to true (it's false by default), the form is automatically closed on a successful save (no broken rules or warnings).

The mmButtonSave.Enabled property is automatically set to True when the associated business object adds new data.

mmButtonClose

This button simply calls the parent form's Close method.

Associating a Business Object with the Specialized Buttons

When you associate a business object with a specialized button at design time, it causes the button to call methods of the business object at run time. In reality, the button passes the business object reference to a form-level method that in turn calls the appropriate method on the business object.

For example, if you associate an Orders business object with an instance of the mmButtonSave class, when the button is clicked at run time, the button passes a reference to the Orders business object to the form-level Save method which in turn calls the Save method on the business object.

To associate a business object with a specialized button, do the following:

  1. Select the button in design mode

  2. Go the Properties Window and select the BindingSource property

  3. Select the ellipses button next to the property which displays the Binding Source Selection dialog:

  4. Select the business object you want to associate with the button and click OK. This sets the BindingSource property to the specified business object.

  5. If you are working with MM .NET classic business entities and you want the specialized button to work with the business object's default table, you can skip this step. However, if you want to the button to work with a different table or data view of the business object, enter the name of the table or data view in the BindingSourceMember property.

    If you want to bind to a different table, just enter the table name. For example: CustomerOrders.

    If you want to bind to a data view, enter the name of the table the data view is associated with, a period, and the name of the data view. For example: Orders.dvOrdersByEmployeeID.


    Note: This binding is different than the normal data binding for Windows Forms controls. This type of binding does not change any properties of the specialized button as is usually the case with regular data binding. Rather, the data binding specifies which business object, and table or view should be affected when the button is clicked at run time.


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