PowerBuilder – Simple ‘Windows Standard’ Row Selection

Posted on Friday, May 21st, 2010 at 8:20 pm in

Allowing for ‘Windows Standard’ muli row selection is pretty straight forward.  By ‘Windows Standard’ I mean you can select a range by clicking on a row, holding the shift key and clicking on a second row to select all the rows between the two or by holding down the control key and clicking you can select multiple rows (or unselect one previously selected without unselecting all the others).  Anyway the code is in the clicked event of the datawindow.

ll_selectedrow = getselectedrow(0)
// select range
IF KeyDown(keyShift!) THEN
   IF ll_selectedrow = 0 THEN
      This.SelectRow(row, True)
   ELSE
      This.SelectRow(0, False)
      IF row > ll_selectedrow THEN
         FOR ll_rc = ll_selectedrow TO row
           This.SelectRow(ll_rc, True)
         NEXT
      ELSE
         FOR ll_rc = row TO ll_selectedrow
            This.SelectRow(ll_rc, True)
         NEXT
      END IF
   END IF
// multi select
ELSEIF KeyDown(keyControl!) THEN
   IF This.IsSelected(row) THEN
      This.SelectRow(row, False)
   ELSE
      This.SelectRow(row, True)
   END IF
// single select
ELSE
   IF This.IsSelected(row) THEN
      This.SelectRow(0, False)
      This.SelectRow(row, True)
   ELSE
      This.SelectRow(0, False)
      This.SelectRow(row, True)
   END IF
END IF
You might also be interested in

Top