Highlight, HighlightRow,
HighlightRowLineWidth
These three properties, along with the
SelectOnEntry property of the controls within a grid's cells,
determine whether cell contents in a grid are highlighted when
you move into the cell. The effects you can create with them are
a little strange.
Usage
|
grdGrid.HighlightRow = lColoredBorder
lColoredBorder = grdGrid.HighlightRow
grdGrid.Highlight = lAllowHighlights
lAllowHighlights = grdGrid.Highlight
grcGrid.HighlightRowLineWidth = nHighlightRowWidth
nHighlightRowLineWidth = grcGrid.HighlightRowLineWidth
|
There are two kinds of highlighting for each cell in a
grid. First, there's a focus highlight that indicates which cell
has focus—the border of the cell is colored. This highlight is
controlled by HighlightRow, which was added in VFP 5. When you
turn this one off, you don't actually get rid of the focus
highlight—it just changes from colored and noticeable to a just
barely visible thickening of the cell border. It appears that the
non-highlight is always a pale gray, though, no matter what color
your grid lines are. VFP 7 added a new capability to surround the
whole record with a line. If HighlightRow is true, then the
record has a box just inside the grid lines drawn to the width
specified in the HighlightRowLineWidth property. This property
can have a value from 0 to 7. Fair warning: Borders wider than 2
pixels can look pretty strange. They can be drawn over the first
part of the first character in a left-justified first column, and
can do the same to the right-justified character in the last
column. This isn't the most aesthetic way of highlighting a
row.The second kind of highlight pertains to a grid cell.
Normally when you tab into a grid cell, the text there is
selected (highlighted). Two properties can change this. Highlight
changes it for the whole grid. By default, it's True, setting
highlighting on for all columns of the grid. We'd be inclined to
turn highlighting off when a grid is read-only. The highlight
confuses people in that case.The other property that controls
highlighting is the column's SelectOnEntry. Once you turn
highlighting on for the grid, you can then control each column
individually.We should point out that, even with all the relevant
settings turned on, you don't get the whole row highlighted the
way you do in lists. Even with VFP 7's HighlightRowLineWidth
property, you still get an interesting effect (when wide lines
are used, say, greater than HighlightRowLineWidth = 2, well,
let's just say they're not quite up to our aesthetic standards).
Grids are not lists, and you would have to do some more tricks,
including setting DynamicBackColor for every column. Christof
Lange published a very complete solution to the problem in the
Ask Advisor column in the November '98 issue of FoxPro
Advisor.When HighlightRow is .F., but Highlight is .T., the
highlighting of individual cells looks pretty strange.
Example
|
ThisForm.grdReference.HighlightRow = .F. && No focus highlight
ThisForm.grdReference.Highlight = .F. && No highlight of
&& contents, either
* This sets the highlight box to 2 pixels wide
ThisForm.grdReference.HighlightRow = .T. && Turn on highlight
ThisForm.grdReference.HighlightRowLineWidth = 2
|
Back to Table of Contents
Copyright © 2002-2018 by Tamar E. Granor,
Ted Roche, Doug Hennig, and Della Martin. Click for license
.