|
|
|
|
|
- Lesson 5 - Creating a drop-down menu
- Overview
- Creating a drop-down menu
- Creating an option to print a report
- To sum up
Tutorial - Managing data in a WINDEV application
Lesson 5 - Creating a drop-down menu We will cover the following topics: - Creating a drop-down menu.
- Printing a report programmatically
 30 min In the previous lesson, we created a report to list customers. But this report has not yet been integrated into the application. The user has no way of opening it. To print this report, we will use a drop-down menu, a very common feature in Windows applications. Let's create a drop-down menu in the Menu window of "WD Full Application". We will modify it to print a report. Then, we'll see how to print a report programmatically. Creating a drop-down menu Once our report is complete, we will create a menu in the "WIN_Menu" window to directly print the report. To insert a drop-down menu in "WIN_Menu": - Open "WIN_Menu" in the editor (double-click its name in the "Project explorer" pane, for example).
- On the "Window" tab, in the "Bars and menus" group, expand "Main menu" and select "Add main menu".
- A menu is inserted into the window, below the title bar. This menu contains an option named "Menu".
Let's add the different menu options. First, let's add a menu option for exiting the application. This option will be a sub-entry of the "Menu" option. - In the editor, select the "Menu" option.
- Right-click to open the context menu and select "Transform to expand a submenu".
- In the input area that appears, type "Exit".
- We are going to associate this menu option with the "Alt + F4" shortcut:
- Select the "Exit" option.
- Right-click to open the context menu and select "Option description".
- On the "General" tab, in the "Keyboard shortcut" area, select "F4" and check "Alt".
- Validate.
Now let's write the code of this option: - Select "Exit".
- Right-click to open the context menu.
- Select "Code". The code editor appears.
- Write the following WLanguage code in the "Select a menu" event:
IF YesNo(No, "Exit application?") = Yes THEN
EndProgram()
END
Let's take a look at this WLanguage code:- YesNo is used to establish a dialog with the user by asking a question. The user can answer the question by clicking a Yes or No button.
- EndProgram (called if the user clicks "Yes") is used to end the application.
Creating an option to print a report We will now create the options for printing the report: - Select the "Menu" option.
- Right-click to open the context menu.
- Select "Add an option after".
- In the input area, type "Reports".
- Select the "Reports" option:
- Right-click to open the context menu.
- Select "Transform to expand a submenu".
- In the input area that is displayed, type "List of customers". Press Enter to confirm.
The report will be printed via the "List of customers" option. Let's write the corresponding WLanguage code: - Select the "List of customers" option in the editor.
- Right-click to open the context menu.
- Select "Code". The code editor appears.
- Write the following code in the "Selecting the menu" event:
iDestination(iViewer)
RPT_list_of_customers.Print()
Let's analyze this code:- iDestination allows you to configure the print destination. You can generate a report to be printed:
- in a text file,
- in HTML format,
- in PCL format,
- in PDF, RTF, XLS or XML format,
- on a fax.
In our case, the report will be generated in the report viewer window. - <Report>.Print is used to print reports.
Test the window and its menu options by clicking  in the quick access buttons.  Completed project Do you want to check the end result of the steps described here? A completed project is available. This project contains the different windows created in this lesson. To open the completed project, go to the home page and click "Tutorial", then in "Tutorial - Full application with data", click "Open completed project". In this lesson, we discovered how to create a drop-down menu and allow the user to print a report. In the next lesson, we will see how to show statistics using the Chart and Pivot Table controls.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|