Example: Opening a Dialog from a Property Sheet

In this example, we will add a button to a property sheet tab, to open a dialog box, allowing you to enter additional personal details for a person.

This example builds on the extension file developed in Example: Including a Form in a Form.
  1. Open the Personal Details form under the Person metaclass, and select Dialog Box in the Type field, to transform it from a property sheet tab into an independent dialog:

    Example - Dialog Box 1
  2. Right-click the Person metaclass and select New > Method. Enter the name ShowPersonalDetails, and then click the Method Script tab and enter the following script:
    Sub %Method%(obj)
     ' Show custom dialog for advanced extended attributes 
     Dim dlg
     Set dlg = obj.CreateCustomDialog("%CurrentTargetCode%.Personal Details")
     If not dlg is Nothing Then
      dlg.ShowDialog()
     End If
    End Sub
  3. Select the Contact Details form, and click the Add Method Push Button tool, select the ShowPersonalDetails method, and then click OK to add it to the form. Here, I use a horizontal layout and spacer to align the button with the right edge of the form:

    Example - Dialog Box 2
  4. Enter Personal... in the Label field, and then click OK to save your changes and return to the model. Now when you open the property sheet of a person, the Contact Details tab contains a Personal... button which opens the Personal Information dialog:

    Example - Dialog Box 3