Skip to Content
Author's profile photo Shenn Sellers

Custom Row Highlighting

Are you tired of using the standard row highlighting within PowerBuilder DataWindows?

/wp-content/uploads/2013/09/crh0_277470.jpg

If you are ready to spruce things up and make it more modern looking then give my Custom Row Highlighting example a try.

/wp-content/uploads/2013/09/crh1_277414.jpg

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.

/wp-content/uploads/2013/09/crh_277451.jpg

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.

  1. 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).
  2. 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.

/wp-content/uploads/2013/09/crh2_277469.jpg

Holding down the CTRL key and clicking on rows allows you to select multiple rows.

/wp-content/uploads/2013/09/crh3_277465.jpg

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.

/wp-content/uploads/2013/09/crh4_277466.jpg

To change the highlighting colors of the rows is as easy as entering a new RGB value.

/wp-content/uploads/2013/09/crh5_277467.jpg

This picture shows when I changed the RGB values to Green and Pale Green.

/wp-content/uploads/2013/09/crh6_277468.jpg

  • 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.

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Shenn;

        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

      Author's profile photo Shenn Sellers
      Shenn Sellers
      Blog Post Author

      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.

      Author's profile photo Former Member
      Former Member

        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.  🙂

      Author's profile photo Former Member
      Former Member

      Thanks a lot , I was looking this since long time ...

      Alfredo