Tuto WINDEV 25
148 Part 4: Full application with data ▶ We will now write the WLanguage code associated with the "Validate" Button control. 1. Right-click the Button control and select "Code" from the popup menu. 2. Write the following code in the "Click" WLanguage event: ScreenToFile() HModify(Product) Close() Let’s take a look at this WLanguage code: • ScreenToFile is used to initialize the items with the values of linked controls, for the current record. This function is equivalent to the following code lines: Product.Reference = EDT_Reference Product.Caption = EDT_Caption Product.Description = EDT_Description ... Our window is using less than 10 controls and the benefit is already there; think of the windows that use a lot more controls: a single code line performs all assignments! • HModify is used to update the file data for the current record. 3. Save the modifications by clicking among the quick access buttons. 4. Close the code window (click X at the top right corner of code editor). ▶ The modifications performed in the "WIN_Product_form" window must be taken into account in the Table control used to list the products. To do this, we will simply modify the WLanguage code associated with the "Modify" Button control in "WIN_Menu". 1. Display the "WIN_Menu" window in the editor: click the corresponding button in the button bar. 2. Select the "Modify" Button control and open the code editor (F2). 3. Modify the "Click" event as follows: Open(WIN_Product_form) TableDisplay(TABLE_Product, taCurrentSelection) Let’s study this code: • TableDisplay is used to update the Table control. • The taCurrentSelection constant is used to specify that the Table control must be updated from the position of selection bar. 4. Save the modifications by clicking among the quick access buttons. 5. Close the code window (click X at the top right corner of code editor).
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==