Saturday, July 14, 2018

Managed Host

Microsoft Dynamics AX supports the display of .net managed controls. Actions
taken by the user on those controls are also handled. The following procedure
shows how to add a windows calendar control to a form and handle an event that
arises from a user action.


1. In the AOT, right-click on the
Forms node and select New Form.

2. Rename the new form to
DateDifferenceCalculator.

3. Right-click on the
Design node and select New Control >ManagedHost. The Managed control selector form appears.

4. In the list find the
System.Windows.Forms record.

5. In the
Controls list, select MonthCalendar. Click OK.

6. Rename the new ManagedHost control to
CalendarControl.

7. Right-click
CalendarControl and select Events. The Events form is
displayed.


8. Highlight
DateSelected and click Add.

9. Click
Close.

10. Open the Init method of the form. Note that code has been added to
initiate the control and also the
DateSelected event handler.

11. Open the
CalendarControl_DateSelected method. Add the
following code.



1
2
3
4
5
6
utcDateTime dt;
date selectedDate;
dt = e.get_Start();
selectedDate = DateTimeUtil::date(dt);
info(strFmt("Number of days until %1 is %2", selectedDate,
selectedDate - systemDateGet()));

12. Save your changes to the form.

13. Open the form and click on different dates to see the number of days
from now until that date.


Best Regards,
Hossein Karimi

No comments:

Post a Comment

Configure the Firewall on the Enterprise Portal Server

After you install Enterprise Portal, enable Web Server (HTTP) in Windows Firewall. If you do not enable the web server in Windows Firewall...