Example Program - Block filling a grid control
The following program fills a grid with random numbers. It demonstrates the RowRequest() event which is triggered when the user scrolls to the end of the grid and the DataPending property is still TRUE. When the program runs out of data at 500 rows it leaves the DataPending property in its default FALSE value.
If you click on the grid and then press page down you will notice that the grid automatically adds the next block of rows. The same is true if you scroll down through the grid with the scroll bar.
DEFFORM Form1()={.form,.form$,.Style=0x50C000C4,.Width=310,.Height=196,.Text$="Block filled grid example",.Id=1024},\ {.ok,.button$,.Style=0x50010001,.Left=255,.Top=6,.Width=50,.Height=14,.Text$="OK",.__Anchor=5,.Id=1},\ {.cancel,.button$,.Style=0x50010000,.Left=255,.Top=23,.Width=50,.Height=14,.Text$="Cancel",.__Anchor=5,.Id=2},\ {.txtControl1,.static$,.Style=0x50000000,.Left=18,.Top=130,.Width=197,.Height=55,.Text$="Notice that when you pull down the scroll bar, or if you page down the grid continues to grow. The grid will not grow beyond 500 entries.",.Id=1001},\ {.GridControl1,.KCMLgrid$,.Style=0x50010030,.Left=8,.Top=7,.Width=233,.Height=110,.Id=1000,.Rows=10,.Cols=8,.FixedRows=1} DEFEVENT Form1.Enter() REM fill an initial ten rows LOCAL DIM row,col FOR row = 1 TO 10 FOR col = 1 TO 8 IF (col == 1) .GridControl1.Cell(row, col).Text$ = row CONTINUE END IF .GridControl1.Cell(row, col).Text$ = INT(RND(1) * 1000) NEXT col, row .GridControl1.DataPending = TRUE END EVENT DEFEVENT Form1.GridControl1.RowRequest() REM Grid wants new row, give it another 10 LOCAL DIM row,col ..Rows = ..Rows + 10 FOR row = ..Rows - 9 TO ..Rows FOR col = 1 TO 8 IF (col == 1) ..Cell(row, col).Text$ = row CONTINUE END IF ..Cell(row, col).Text$ = INT(RND(1) * 1000) NEXT col NEXT row IF (..Rows < 500) ..DataPending = TRUE END IF END EVENT FORM END Form1 Form1.Open()