Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: Ovette Abejuela
  Where is Ovette Abejuela?
 Cagayan de Oro City
 Philippines
 Ovette Abejuela
 Tags
Subject: RE: Grid: Count Number of Fileds
Thread ID: 143139 Message ID: 143148 # Views: 2 # Ratings: 1
Version: Visual FoxPro 9 Category: Grids
Date: Saturday, August 25, 2007 10:53:41 AM         
   


> Hi,
>
> I'm just starting to explore grids and hopefully uncover every possible things I can do with it and along the way this is the first problem that I have:
>
> - I have a grid in a form which takes data from a local view
> - this grid's number of columns is dynamic (default Grid1.ColumnCount = -1)
> which will accommodate the number of fields of its record source
> - now i actually need to traverse through all the columns but since its
> dynamically created i presumably do not know as to how many columns/fields
> this particular field have.
> - bottom line, Id like to know if there is a way to find out as to how
> many fields/columns are there present in that particular grid.
>

> I really do appreciate your help, thank you.
>
> -zbatev

Grid.ColumnCount would give you the number of columns it shows anytime. You could loop the columns with their indexes:

for ix=1 to myGrid.ColumnCount
myGrid.Columns[m.ix]

or with for each.

ColumnCount and Field count are irrelevant. A grid might show less or much more columns then what its underlying source(s) have. When bound to a single source and no calculated columns, no change in columncount (readwrite property) then they match. Likewise their order (column order vs field order) need not be the same. Prefer "for ix=1 to ..." style over "for each" IMHO. Columns' index doesn't change once its setup even if their ColumnOrder changes.

"uncover every possible things I can do with it" is a good wish:) It's a huge subject that deserves a separate book. I have been working with grids for years and I still couldn't get to that point yet (but since now there won't be a new VFP version, its capability enhancements ceased maybe I can catch up).
Once you get a hang on it you soon realize that it's the most powerfull control in VFP (after the most powerfull command of all times - browse).

Cetin Basoz

ENTIRE THREAD

Grid: Count Number of Fileds Posted by Ovette Abejuela @ 8/25/2007 9:08:17 AM
RE: Grid: Count Number of Fileds Posted by Borislav Borissov @ 8/25/2007 9:13:50 AM
RE: Grid: Count Number of Fileds Posted by Ovette Abejuela @ 8/25/2007 9:39:34 AM
RE: Grid: Count Number of Fileds Posted by Ken Murphy @ 8/25/2007 2:25:06 PM
RE: Grid: Count Number of Fileds Posted by Ovette Abejuela @ 8/25/2007 3:58:42 PM
RE: Grid: Count Number of Fileds Posted by Cetin Basoz @ 8/25/2007 10:53:41 AM