Live selection operation in the data window

xiaoxiao2021-03-06  37

We need to enter the line in the data window. If the user selects a certain row in order to modify data or see more detailed content; in other cases, the user may be deleted or modified simultaneously. At this time, we need to make the user select more simultaneously in a data window. The function of the line. This is easier to do in PowerBuilder, but, if you don't have a standard function in a data window, you will be repeated in each window, which is more annoying.

Let's first look at the different way to see the selection of the line.

All rows do not brighten

The standard line of the data window is not bright. This is very simple, you don't need to do it. This method is suitable for those data lists that only allow users to scroll and see, or those of those single-line data windows.

Single line selection

Single line selection means that only one line can be selected at the same time. Select a line in the user to perform some movements, such as deleting or displaying a detailed information in the list of the main slave system, which is commonly used. The lower surface is the code that is now allowed to select the single-line selection function:

Event: RowFocuschanged

IF getRow ()> 0 THEN

SELECTROW (0, FALSE)

SELECTROW (GetRow (), TRUE

END IF

Multi-line self-timing

When you select a multi-line auto, the row will brighten when you use an apartment. If you use a household to click a brightening line, the line will not be bright.

In order to realize the above, you can put the following code into the RowFocuschanged event:

Event: RowFocuschanged

Event: RowFocuschanged

Object: Any DataWindow

IF getRow ()> 0 THEN

IF isselected (getRow ()) THEN

SELECTROW (GetRow (), FALSE

Else

SELECTROW (GetRow (), TRUE

END IF

END IF

Or simplify the following line of code: if getrow ()> 0 Then SELECTROW (GetRow (), not isselected (GetRow ())) Hold down Shift, Control or Control Shift Click on the Mouse using Windows file manager or other Windows In the program, you can use the combination of SHIFT, Control or Control Shift to change the selection behavior. PowerBuilder has no ability to provide this in the data window, we must be self-satisfied. The combined function we should implement is: Press the key action without only highlighting the current line, set the display of other rows to maintain the status of other rows, and increase the current line to the current line to the current line All rows between the other rows are set to normal control-shift to maintain the status of other rows, and highlight all rows between the starting lines to the current line, establish such functions, we first need to start the line Track. When the user uses a SHIFT or Control-Shift key, the system should highlight all the rows selected by the front user mouse click or keyboard to the starting line of the starting line of the previous operation. Therefore, the data window must record the starting line before the record. We declare such an instance variable: protected long il_anchor_row When the user clicks on the mouse or performs the keyboard operation, we want to test whether the user presses the Shift or Control key, use the keydown () function, check if there is any keyshift! And keyControl !, If such a key is pressed, record the starting line. Writing line selection functions

For the above-in-one hit mouse or on the keyboard operation, the above line is generated, and we must call our own row-choice functions in the Clicked event and a reputation event that maps to the PBM_DWNKEY event. In this way, it is not a hitting a mouse or hits the middle button, and the selection is available. You can also put this function into the RowFocuschanged event. In order to make this line choose to reuse, we set up two functions. A function set up the selection line of our hopes, and the other is truly executable to the selected line. First of all, we use an instance variable to set the value of the selected line: protected integer II_SELECT_BEHAVIOR This variable will put some of the values ​​below. Possible Selection Behavior Behavior 0 Does Select Behavior 1 Allows One Ring Selection 2 Automatic Multi-Row Selection 3 Allows the Use Mouse and Keyboard Combination Selection 99 Do not allow selection, turn the mouse into a hand type If you use protection variables Or private variables that this means that procedures other than this object cannot be accessed, so you must establish a function that assigns assignments to these variables and acquiring these variables for other programmers. In addition, you also need some functions to execute the process based on this variable. Function: uf_setselect (select_behavior) The first function I have to write will allow the allowable sequence to set the selected line. Function: Public Integer Uf_setSelect (Integer Ai_Select_behavior) / * This function sets the selected line of the data window, the value of the value is the valid selection line is the value * / choose case ai_select_behavior

Case 0, 1, 2, 3, 99

II_SELECT_BEHAVIOR = ai_select_behavior

// At least one line will be selected

IF AI_SELECT_BEHAVIOR = 1 THEN

UF_Process_Select (GetRow (), "keyboard")

END IF

IF AI_SELECT_BEHAVIOR = 99 THEN

SetrowFocusindicator (Hand!)

Else

SetrowFocusindicator (OFF!)

END IF

Return 0

Case Else

Return -1

End chaoose

Function: uf_processselect (long al_row, string as_input_type) Once select type is set, the rows must be processed. I put this part of the code into a function called UF_ProcessSelectselect. This function is responsible for selecting a line. You need to tell the function that you want to process and the request is sent by the mouse or the keyboard. The next is the function: long L_ROW

Boolean B_Reset_anchor

Boolean B_Keyboard, B_Mouse

// mouse action or key disk movement?

IF Upper (AS_INPUT_TYPE, 1) = "k" Then

B_keyboard = TRUE

Else

B_mouse = true

END IF

/ * Ensure the mouse points on the record of the data window * /

If Al_Row <1 Then Return 1 / * To determine the starting line * / b_reset_anchor = "true" setREDRAW (false) / * valid operation value 0 = "Not" allows the selection behavior 1 = "only" Allow a line to select 2 = "Self" dynamics Multi-line selection 3 = "" 许 使用用 选择用 99 = "Not" allowed to select, turn the mouse into a hand * / choose case 0, 99 // No Case 1 / / Unlining Selectrow (0, False) SELECTROW (Al_Row, True) Case 2 // Multi-line Select IF B_Mouse Then Selectrow (al_row, not isselected (al_row)) end if case 3 if keydown (keyshift!) And keydown (KeyControl! ), If il_anchor_row> Al_row Then

For L_Row = IL_ROWOR_ROW TO Al_Row Step -1

this.selectrow (L_Row, True)

NEXT

Else

For L_Row = IL_Anchor_row to al_row

this.selectrow (L_Row, True)

NEXT

END IF

Elseif KeyDown (Keyshift!) THEN

SELECTROW (0, FALSE)

IF IL_ANACHOR_ROW> Al_Row Then

For L_Row = IL_ROWOR_ROW TO Al_Row Step -1

this.selectrow (L_Row, True)

NEXT

Else

For L_Row = IL_Anchor_row to al_row

this.selectrow (L_Row, True)

NEXT

END IF

B_RESET_ANACHOR = FALSE

Elseif KeyDown (KeyControl!) THEN

SELECTROW (al_row, not isselected)

Else

SELECTROW (0, FALSE)

SELECTROW (Al_Row, True)

END IF

End chaoose

SetredRaw (TRUE)

IF b_reset_anchor thein il_anchor_row = al_row

Return 0

Now, when we hope to choose the selection, the whole operation to be done is to call the UF_ProcessSelect () function. This function is called when you hit the mouse in a data window or press the down, down arrow keys, call this function. There are also code that captures the Home and End keys. The following is the code in the WE_KEYDOW user event (mapping to the PBM_DWNKEY event):

Event: WE_KEYDOWN (PBM_DWNKEY)

Object: Any DataWindow

IF keydown (keydownArrow!) and getrow () <> rowcount () THEN

Uf_ProcessSelect (GetRow () 1, "Keyboard")

Elseif KeyDown (KeyuParrow!) and getrow () <> 1 THEN

UF_ProcessSelect (GetRow () - 1, "keyboard")

Elseif KeyDown (KeyHome!) And Rowcount ()> 0 THEN

UF_ProcessSelect (1, "keyboard")

Elseif KeyDown (Keyend!) And Rowcount ()> 0 THEN

Uf_ProcessSelect (Rowcount (), "keyboard")

END IF

At the end, we need to join in the Clicked event:

UF_ProcessSelect (getClickedRow (), "mouse")

In this ancestor's first function, the function is written in this way is just as a simple instance. Let you have a certain function, you can write more functions, to expand the basic function of the exhibition data window.

转载请注明原文地址:https://www.9cbs.com/read-63414.html

New Post(0)