Appframe Knowledge Base


1 hits
0

How to open form while passing optional values

' Sometimes you might want to accept optional values in a CR4 form. The
' assembly loader provides a facility to pass constructor arguments, but
' this may be too rigid. The OpenProperty facility allows you to pass
' and read optional values of any type without depending on constructor
' signatures.

' The following code shows how to open a form while passing values to it:

Public Sub cOpenSetup_Click(pSender As Object, pArgs As EventArgs) handles cOpenSetup.Click

	Dim vProjectName = cProject.SelectedValue

	Dim vArgs As New OpenFormArgs("App.Example.ProjectManagement", "ProjectSetup")
	vArgs.AddProperty("ProjectName", vProjectName)
	vArgs.AddProperty("SummaryVisible", False)

	CR3.OpenForm(vArgs)

End Sub

' The following code shows how to access the passed values in the newly
' opened form defined in another project:

Private Sub MyForm_Load(ByVal pSender As Object, ByVal pArgs As EventArgs) Handles Me.Load

    If HasOpenProperty(Of String)("ProjectName") Then
        cProjectChooser.EditValue = GetOpenProperty(Of String)("ProjectName")
    End If

    If HasOpenProperty(Of Boolean)("SummaryVisible") Then
        cSummaryPanel.Visible = GetOpenProperty(Of Boolean)("SumamryVisible")
    End If

End Sub

win · Perma link post comment Posted by: Jarl Erik Schmidt (08-mai-2012)