Quick Tip: Highlight the Active Row in a Browse

 by Jack Wheeler

Jack (jwl1@jps.net) shows you how to highlight the active record on a browse.

  A client asked if I could Hi-light the current record of a browse to match all the fields on the forms. I was not aware that the active row of a browse was not hilighted when he called me. I soon fixed that! This technique works so well that I have included it on all my embedded browses! All my embedded browses now always show the active row highlighted in the same colors as all the fields on the form, as in this form below. A nice touch!

tip4a

Here's what I did:

  1. On the form, I created a session-level variable named Rec4. (You can give it any name you like - I chose Rec4 because it is unlikely to conflict with any other variables on the same form.)
  2. I set Rec4 to the record number of the currently active record.
  3. In the color equation and font equation for the browse's columns, I check to see if the row's record number is the same as Rec4. If it is, I highlight the row.

Here is where the color and font equations equations are found:

tip4

The session variable, Rec4, is reset in the OnArrive and the OnRowChange events of the browse in this script:

var->rec4=table.current().recno()
browse2.refresh()

Here is the Color Equation:

If(recno()=var->rec4,"blue on eggshell","black on white")

Here is the Font Equation:

If(recno()=var->rec4,"MS Sans Serif, 11,B","MS Sans Serif, 10,")

This works wonderfully. Be careful: when you use the font equation, you must have a comma after your font size, otherwise your font equation will not work. Hope you enjoy this tip!

3/7/00

Don't forget, we need your feedback to make this site better!

Return to home