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.

These grid properties hearken back to the days when people actually used split Browses for data entry. In the never-ending quest for backward compatibility, grids offer the same set of options for side-by-side panels, with each panel able to use either the one-row-per-record Browse mode or the one-row-per-field Edit/Change mode. It’s far easier to set this stuff up in Visual FoxPro than it ever was before, though we don’t see ourselves using it any more than we did—other than for the rare quick-and-dirty dBASE III data-entry situation. Although there are times where a split grid would be handy, given how hard it is to do it well with VFP’s grid, we’re much more inclined to use an ActiveX control in those cases.

Panel determines, in a split grid, which side has the focus. PanelLink determines whether the two sides are linked—that is, if you move to a new record on one side, do you move on the other side, too? View specifies which mode each side of the split uses or, if the grid is unsplit, which mode the whole grid uses.

Usage

grdGrid.Panel = nWhoHasFocus
nWhoHasFocus = grdGrid.Panel
grdGrid.PanelLink = lLinked
lLinked = grdGrid.PanelLink

These two are relevant only when Partition is positive—that is, when the grid is split into two panes (or panels). Use Panel to programmatically set focus to one side or the other, or to see where focus is.

PanelLink actually controls more than just what happens if you move the record pointer. A number of the visual properties can be applied either to both sides or to just the current side, depending on the value of PanelLink. (See Help for a list of the affected properties.) Fortunately, you can unlink the panels, make some changes, then relink them by manipulating PanelLink. Unfortunately, since you can see the properties of only one panel at a time, it’s easy to get confused when you’re doing this.

Usage

grdGrid.View = nModes
nModes = grdGrid.View

This misnamed setting has nothing to do with the window formerly known as View (now called Data Session), the kind of views you create with CREATE VIEW, or the views that are members of a database. They’ve overloaded the term yet again.

The value of View determines whether you see Browse mode or Edit/Change mode. If the grid is split, it determines the mode for each side. An unsplit grid is treated like the right panel, so you need to SET VIEW to 1 (Browse Change) or 3 (Change Change) to get record-at-a-time editing.

The design-time appearance of a grid (or panel) in Change mode is totally useless. You can't tell anything about it.

If you put controls other than text boxes in a grid, when you change the grid to use Change mode, it still uses your controls. (Of course, we haven't used a grid in Change mode yet.)

Example

* Split the grid
ThisForm.grdMyGrid.Partition = 100
* Now use Browse mode on the left, Edit/Change mode on the right
ThisForm.grdMyGrid.View = 1
* Unlink the two panels
ThisForm.grdMyGrid.PanelLink = .F.
* Set up each side the way you want it
ThisForm.grdMyGrid.Panel = 0   && Left
ThisForm.grdMyGrid.RowHeight = 30
ThisForm.grdMyGrid.GridLineColor = RGB(255,0,0)
ThisForm.grdMyGrid.Panel = 1   && Right
ThisForm.grdMyGrid.RowHeight = 25
ThisForm.grdMyGrid.GridLineColor = RGB(0,0,255)

See Also

Grid, Partition