I have two stringgrids on different tabs of a page control.
For stringgrid1, I issue stringgrid1.clear, then fill the grid's cells, by column and row within 2 nested for loops, parsing the cell data from a tstringlist.
After processing the stringgrid1, I want to move to the tab containing stringgrid2.
I issue stringgrid2.clear, then attempt to copy a portion of stringrid1 to stringgrid2, cell by cell, using nested for loops.
The result is an error, that stringrid2[0,0] is out of range.
If I don't use stringgrid2.clear, it works.
Both stringgrids are identical.
Because the user can flip back and forth between stringgrids 1&2, I need to be able to initialize both, each time stringrid1 is changed.
However, it seems like while stringgrid1.clear initializes it correctly, stringgrid2.clear removes all of the grid's rows and columns and doesn't permit me to copy in new data.
I realize there are many possibilities, but any ideas why stringgrid.clear is behaving differently for my two stringgrids? Which is the "correct" behaviour?
Do I need to fill my stringgrid2 with empty spaces to ensure it is empty?