Answer
Very often it is necessary to update the text of an Edit control when the user clicks a button which resides on the same dialog. The content of the Edit control will be modified using a UI custom action (which is launched by a DoAction published event associated with the button control).
The general method to achieve this task consists in defining two published events associated with the button control:
- A DoAction published event which invokes your UI custom action that sets a property. For simplicity, this property can be that attached to the Edit control. For more details on how to define such a Custom Action see Execute custom action on button push.
- A SetProperty control event which sets the property associated with the edit control to the value of the property set by the custom action.
For instance, suppose that the property attached to the Edit control is named MY_EDIT. Consider also that the custom action sets this property (MY_EDIT) to the appropriate value. In this case the DoAction control event will be configured as follows:
- Event Name: DoAction
- Argument: Select the custom action that sets the MY_EDIT property
- Condition: 1
The SetProperty control event will be configured as follows:
- Event Name: [MY_EDIT]
- Argument: [MY_EDIT]
- Condition: 1
If the SetProperty control event is not defined, the property will
be set correctly, but the edit control will not be updated until the
user leaves the current dialog.
Due to a Windows Installer issue, the edit control will not be updated with
the correct value if the user types in the Edit control before pressing
the button. In order to avoid this issue you can use an Advanced Installer predefined
custom action, as described below.
- In the Custom Actions page add the "Update MSI Edit Controls" predefined custom action under UI Custom Actions section.
- Add another DoAction published event to the
button that modifies the edit control and make sure that this control
event comes before the control events you specified above:
- Event Name:DoAction
- Argument: UpdateMsiEditControls
- Condition: 1
Instead of using a control event to invoke the UpdateMsiEditControls
custom action, you could invoke it directly from your UI custom
action
If you are using a C++ DLL Custom Action you would use:
MsiDoAction(hInstall, _T("UpdateMsiEditControls"));In a VBScript custom action the code would be:
Session.DoAction("UpdateMsiEditControls")