Deeply understand the processing mechanism of data entry of PB data window

Source: Internet
Author: User

Author: Xingda Computer technology company (www.study01job.com) Guo Baoli

Dealing with Data window controls is done by editing controls. Entering data and modifying data in a data window is actually modifying the contents of the edit control on the cell. When the edit control is moved to another cell, verify the data in the edit control, and save it to the field if it passes the validation rules for the field. Edit controls can be moved, which cells need to be edited, which cell the edit control moves to, and accept input or modify.
For people who are familiar with Microsoft Excel, the edit control can be viewed as a cell in an Excel grid. When a user enters a formula in a cell, it is not accepted and evaluated until the user moves to another cell, and the formula is checked for correctness, and if the error is not moved to another cell. The Data window control uses the same concept.
When an edit control does not leave the current field, the data entered or modified by the user is not saved in the field, and how do you ensure that the contents of the edit box in the last position are not omitted when the data window loses focus? The following scripts are written in the Losefocus event of the data window:
This. Accepttext ()
This method can solve the problem in many cases. The drawback is that if the contents of the edit box do not pass the field's validation rules, sometimes two error message windows are displayed. Creates two error message windows, often when other cells are selected, and only an error message window is displayed before the data window loses focus (such as clicking the Save button). When the user selects another unit, the data in the edit box starts to verify, cannot pass the validation rule, displays the checksum error information, when displays the checksum error information the data window loses the focus, triggers the data window the Losefocus event to execute the Accepttext function, again displays the validation error window.
Therefore, the reason for displaying the two-time checksum error window is caused by the Accepttext function in the Losefocus event. You can think of the function not to execute in this case. Define an instance variable for this:
Boolean ib_accept = True
This variable is used to indicate if the checksum is passed correctly, and then the script in Losefocus is changed to the following script:
If ib_accept Then
This.accepttext ()
Else
Ib_accept = True
End If
Write a script in the Itemerror event of the data window:
Ib_accept = False
This resolves the display of two checksum error information windows and does not omit the contents of the last edit box.
When you modify or enter data in a unit, the edit box will be left with 4 verification steps, the first two steps are completed by PowerBuilder, and the following two are written by the developer.
(1) To see whether the data and edit before the change, no change is not done any processing.
(2) Check to see if this value violates any of the validation rules defined on the field, denies accepting this value, and triggers the Itemerror event.
(3) Check to see if this value is different from what was edited before, and then terminate the validation check without any changes.
(4) Check the scripts written by developers in the ItemChanged event. The exact occurrence depends on the value assigned to the action code called.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.