Custom Row Highlighting
Are you tired of using the standard row highlighting within PowerBuilder DataWindows?
If you are ready to spruce things up and make it more modern looking then give my Custom Row Highlighting example a try.
You are you able to specify any color for the row highlighting, (i.e. Row ID #300 is the selected row). Also as you move the mouse over the other rows in the DataWindow shadow highlighting appears. (The cursor is currently over Row ID #401). The shadow highlighting color may also be specified. This mimics the Windows Explorer behavior introduced in Vista and Windows 7.
The only way to achieve this type of functionality before was using one of two options. None of these options provided you with the Shadow Highlighting option.
- Manually or through a script change the “Selected Items” color in the Windows Color and Appearance. (The big drawback with this is that it changes every program within Windows).
- Inside your DataWindow play with visibility settings on a Rectangle or Text object.
In my example all of this is accomplished through code within the DataWindow and within functions.
Holding down the CTRL key and clicking on rows allows you to select multiple rows.
You may also select a row, hold down the SHIFT key, and click a row above or below the selected row to highlight a cluster of rows.
To change the highlighting colors of the rows is as easy as entering a new RGB value.
This picture shows when I changed the RGB values to Green and Pale Green.
- SelectRow() should not be used. (This will cause the default PB row highlight to be called). Instead just use SetRow() and the code will take care of the rest.
- Use the f_count_selected_rows() function in place of the built in PB function RowCount().
- Use f_is_row_selected() in place of the built in PB function IsRowSelected().
- Use f_return_selected_rows() to return an array of all the selected rows in the DW.
To download the example Pibble click on this link https://drive.google.com/folderview?id=0B6J5FirdQZqucFhoZXdmeC14WHM&usp=sharing
The example Pibble was created using PB 12.5. If someone needs a lower version I could also create a PB 11.5 version.