Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

GridLineColor, GridLineWidth

These two properties, not surprisingly, determine the color and width of a grid’s lines between cells.

Usage

grdGrid.GridLineColor = nRGBValue
nRGBValue = grdGrid.GridLineColor
grdGrid.GridLineWidth = nWidth
nWidth = grdGrid.GridLineWidth

The color setting for GridLineColor accepts the standard RGB color value, an integer in the range of 0 to 16,777,215, as returned by the RGB() function.

One neat trick to try with GridLineColor is to set the colors of the row and gridlines so the grid seems to disappear at some points. In our example below, a grid set up with white gridlines and the “green-bar paper” effect of every other line alternating green and white (through the use of DynamicForeColor settings) would appear to have white vertical gridlines only in the green rows.

The width setting for GridLineWidth is expressed in pixels and accepts a numeric value from 1 to 40. The decimal portion of the number is ignored. In VFP 3.0, a value of less than 1 causes the gridlines to nearly vanish, leaving nothing but a little remnant at the intersection of the horizontal and vertical gridlines. A value greater than one-half the height of the row hides the entire row.

GridLineWidth and GridLineColor do not affect the widths or colors of the RecordMark or DeleteMark columns, if they are included, nor do they affect the thickness or color of the lines between the headers. We think this takes away from the overall effect of having such fine control over the gridlines, and hope Microsoft considers extending the properties to cover the whole grid.

Example

* Green Column Headers grdGrid1.SetAll('BackColor',rgb(0,192,0),'Header')
* Alternating white and green rows within grid
* This version works only if the grid shows records in
* their physical order.
grdGrid1.SetAll('DynamicBackColor', ;
        "iif(recno()%2=1,rgb(255,255,255),rgb(0,192,0))", ;
        'Column')
grdGrid1.GridLineColor = RGB(255,255,255)  && White lines
grdGrid1.GridLineWidth = 1  && Single pixel width
grdGrid1.GridLines = 2  && Vertical lines only

See Also

DeleteMark, Grid, GridLines, Highlight, HighlightRow, HighlightRowLineWidth, RecordMark, RGB()