How to display a list of files in a grid

I received a question from a customer:

I am trying to find a way to display a grid of files (specifically DBF files) and show them in the order they were created with the dates and file sizes.

I just took the sample code from Add a slider control to your TreeMap to vary how much detail is shown and cut/paste and the result is below.

It uses the AllowCellSelection property which allows the grid to mimic a listbox.

CLEAR ALL

CLEAR

PUBLIC oForm

oForm=CREATEOBJECT("MyForm",ADDBS(GETDIR("c:\program files")),"*.exe",.f.)

DEFINE CLASS MyForm as Form

          AllowOutput=.f. && so '?' output goes to screen

          Width=_screen.Width

          Height=_screen.Height-50

          Width=1024

          Height=798

          PROCEDURE init(cPath as String, cMask as string, fSubDir as Boolean)

                   SET EXCLUSIVE OFF

                   SET SAFETY OFF

                   SET TALK off

                   SET EXACT OFF

                   CREATE table Files (path c(240),fname c(240),fsize n(10,0),timestamp t)

                   this.DoDir(cPath,cMask)

                   INDEX on timestamp DESCENDING TAG t && choose your desired order

* INDEX on fsize DESCENDING TAG fsize

                  

                   this.AddObject("gr","grid")

                   this.gr.AllowCellSelection=.f.

                   this.gr.Visible=1

                   this.gr.Height=thisform.Height

                   this.gr.Width = thisform.Width

                   this.gr.Autofit

                   this.gr.Column3.InputMask="999,999,999"

                   this.Show

          PROCEDURE DoDir(cPath as String, cMask as String)

                   LOCAL n,i,aa[1]

                   n=ADIR(aa,cPath+cMask,"",1)

                   FOR i = 1 TO n

                             INSERT INTO files (Path,fname,fsize,timestamp) VALUES ;

                                      (cPath, aa[i,1], aa[i,2],CTOT(DTOC(aa[i,3])+aa[i,4]))

                   ENDFOR

                   n=ADIR(aa,cPath+"*.*","HD",1) && now without the mask, search for directories

                   FOR i = 1 TO n

                             IF "D"$aa[i,5] && if it's a dir

                                      IF aa[i,1] != '.'

                                                this.DoDir(cPath+aa[i,1]+"\",cMask) && recur

                                      ENDIF

                             ENDIF

                   ENDFOR

ENDDEFINE