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.
FWIW: You can get the same "look & feel" using an empty Text object stretched into a rectangle around the detail band. Then control it using expressions for row visibility and colour. This way, you don't need any scripting on the DW Control. 😉
Regards ... Chris
Yes, you could do that...but then you will need to do it for every single DW you have to make it work. This code you can just plop in a User Object for a DW control, then use your custom UO DW for all your DataWindows needs. No more worrying about empty Text objects.
You could handle that in one DW Control ancestor using the CREATE ( ) method to dynamically add the text object to the DWO as needed. This way you would not need to change any DW's in your application.
The other thing I like about this approach is that it works 100% with the HTML DW, Appeon Web and Appeon Mobile products as well. 🙂
Thanks a lot , I was looking this since long time ...