Pete,
In VFP5/6 you can use Tools, Options, Field Mapping, Multiple to use your own grid class.
When you drop a grid onto a form it only takes the properties of the DBC that are there at that instant, it doesn't read them dynamically from the DBC at runtime. Grids with ColumnCount = -1 will generate using the current view props. You could program your grid class to read them at runtime, or create a builder that updates your grid at design time.
I use a builder like this:
lparameter plForceHeader
if ( pcount() = 0 )
plForceHeader = .f.
endif
if ( type( "plForceHeader" ) != "L" )
plForceHeader = .f.
endif
local n, i
n = aselobj( laJunk )
if ( ( n != 1 ) or ( laJunk[1].BaseClass != "Grid" ) )
wait window nowait "Grid is not selected"
return
endif
atable()
local lcName, lcCaption
for each oCol in laJunk[1].Columns
i = at( ".", oCol.ControlSource )
if ( i > 0 )
lcName = dbcGetProperFieldName( oCol.ControlSource )
if ( ! empty( lcName ) )
oCol.Name = "col" + lcName
endif
if ( ( lower( oCol.Header1.Caption ) == oCol.Header1.Caption ) or ;
( oCol.Header1.Caption == "Header1" ) or ;
empty( oCol.Header1.Caption ) or;
plForceHeader )
lcCaption = dbcGetCaption( oCol.ControlSource )
if ( ! empty( lcCaption ) )
oCol.Header1.Caption = lcCaption
endif
endif
endif
endfor
It works through a grid and renames the columns and updates the Header captions.
I get to drink beer tomorrow seeing that I have a 6 day holiday starting... *g*
>aplogies for the direct mail, I copied your dbcviewprops.prg from your website and it works fine ( thank you ). However I've just discovered a few other things ( I know I'm a bit slow but I don't use that many grids )
>
>1) VFP uses its own grid ( naff ) if you select a view/table from the DE.
>2) If you use your own grid and set the ControlSource to fields in a view, you don't get the view/table captions.
>
>Is there any way to set a grid template?
>Four days to main beer drinking session.