Tuto WINDEV 25

150 Part 4: Full application with data Creating a new product The principle for creating a product is as follows: • In the product list window, we will add a "New" Button control that will open the "Product form" window. • Then, we will modify the code of "Product form" window to manage the addition into the Product data file. Adding a button ▶ To add a "New" Button control into "WIN_Menu": 1. Display the "WIN_Menu" window in the editor: click the corresponding button in the open documents bar. 2. On the "Creation" pane, in the "Usual controls" group, expand "Button" and select "New button". 3.  The shape of the control appears under the mouse pointer. Click in the window: the Button control is created. 4. Position the Button control above the "Modify" Button control (if necessary, reposition the "Modify" Button control). 5. Modify the WLanguage code of this control: • Right-click on the "New" Button control and select "Code" in the popup menu. • Write the following code in the "Click" WLanguage event: HReset(Product) Open(WIN_Product_form) TableDisplay(TABLE_Product, taCurrentRecord) Let’s study this code: • HReset initializes the item variables in the "Product" data file with the default values to manage a new record. • Open is used to open the product form to type the new record. • TableDisplay is used to re-display the Table control. The taCurrentRecord constant is used in this code: the Table control is re-displayed from the current record. 6. Save the modifications by clicking among the quick access buttons. 7. Close the code window (click X at the top right corner of code editor).

RkJQdWJsaXNoZXIy NDQ0OA==