[Pb] several methods for jump using the Enter key in Pb

Source: Internet
Author: User

In applications developed using PowerBuilder, the conversion between controls and data window columns is basically achieved using the Tab key or mouse. For users who have been using character-based terminals for a long time, especially those who frequently process a large amount of data, each data input must jump to the next column by using the Tab key or mouse, however, it is inconvenient to use the Enter key to facilitate data operations. Here, I will introduce several methods to use the Enter key as the Tab key:
1. In the data window, when a user jumps to the row or column, the Enter key is frequently used in the data window. During design, first open the window object, use the Enter key in the mouse to implement the data window to jump to, select the menu item "Declare | User Event ", define User-Defined events for the data window. For example, there is a window named w_sales, the built-in data window dw_sales, the data window has five columns, the column names are column1 ~ Column5: defines the User-Defined event as "dw_sales_key" and the corresponding PowerBuilder event number is pbm_dwnkey. After defining the event, click the Script icon in the toolbar of the data window and select the event dw_sales_key in the select event for programming. The statement is as follows:

If keydown (keyenter !) Then // determine whether the press is the Enter key

Choose case 1 ower (dw_sales.getcolumnname ())

Case "column1"

Dw_sales.setcolumn ("column2 ")

Case "column2"

Dw_sales.setcolumn ("column3 ")

Case "column3"
Dw_sales.setcolumn ("column4 ")

Case "column4"

Dw_sales.setcolumn ("column5 ")

End choose

End if
After programming, compile, save, and call the window, you can use the Enter key to redirect the columns in the data window. Of course, it is recommended that the jump sequence of the Enter key be consistent with that of the Tab key. The jump Order of the Tab key can be defined by defining the "Design | Tab Order" item in the menu bar of the data window. Of course, you can also write the following statement directly under the ItemChanged event in the data window without defining user-defined events:

Int I

I = dw_sales.getcolumn ()

If keydown (keyenter !) And I <6 then

Dw_sales.setcolumn (I + 1)

End if

You can also jump between data columns. Note that the preceding steps are based on the data insertion status. Data Query is another matter. You can program the data according to the preceding statement. During the query, press the Enter key and the cursor will jump down, instead of querying data by row or column, this is mainly because when the system defines the Tab key, it determines that the column number remains unchanged when the carriage return is made, and the row number is incrementally changed, so the above method will cause dislocation. To completely replace the Tab function, you must do other work. In the above two methods, the former statement is too long, and the latter must be changed for the current column value, press Enter to jump. To this end, you can use another method: Define User-Defined events, where the event number is pbm_dwnprocessenter, and the event programming statement is:

Int I

I = dw_sales.getcolumn ()

Dw_sales.setcolumn (I + 1)

You can achieve the jump function and avoid the above problems.

2. The jump between controls in the window is in the window. Because the types of controls are different, it is more complicated to set the jump. You can press Enter to move the focus to set the jump of each control. If the controls are of the same type, the situation would be much easier. Here, I will give you an example: the window is still w_sales, and there are five Commandbutton controls, cb_1 ~ Cb_5: Write the following statement in the window event key:

Graphicobject I

Int j = 0

I = getfocus ()

If keydown (keyenter !) Then

If j = 1 then

J = 0

Return

End if

Post (handle (I), 256, 9, 0)

J = 1

End if

In this way, when you run the window, press Enter to jump between the five controls. To record the last column value in the data window, press Enter to jump to the control. You can add the following statement in the First example:

Case "column5"

Setfocus (cb_1)
You can.

 

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.