Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Default Grid a possibility?
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00160820
Message ID:
00161008
Views:
35
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.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform