Don't set a row property of a TStringGrid to a fixed row!
Having spent hours trying to resolve a problem I only found the cause after starting to post this problem. It wasn't until I tried a simple test for the benefit of an example that I found the problem.
The problem that was happening was as follows:
I am having problems with the top row of the StringGrid duplicating itself. I populate the string grid through code initially on FormShow and it appears perfectly OK if I have FixedRows := 0;
If I have FixedRows := 1; then it mainly duplicates the fixed row but you cannot access the row.
It redraws/repaints itself correctly under the following conditions :
a) You edit the grid and tab off the first row which the user can select (3rd physical row), 1st row is Fixed, 2nd row is a duplicate of 1st and 3rd is the first scrollable ie row 1.
b) You have horizontal scrolling enabled and you scroll to the right.
I have 5 grids on 3 tabsheets. 2 have FixedRows := 0; and give me no problem. The other 3 have FixedRows := 1; and the problem appears to be when the StringGrid container has focus.
Example : I leave the form in design mode on tabsheet1, the grid on this tabsheet duplicates the top row. I look at the grids on tabsheets 2 and 3 and they appear OK. Then on Tabsheet 2 I do something to cause the grid to be rebuilt by my code and then this grid will now duplicate the top, even though it ran the same routine as it did on Formshow at the start, the only difference is the tabsheet containing the grid now is visible.
Answer : Set Row = 1; and NOT Row = 0;
Having spent hours trying to resolve a problem I only found the cause after starting to post this problem. It wasn't until I tried a simple test for the benefit of an example that I found the problem.
The problem that was happening was as follows:
I am having problems with the top row of the StringGrid duplicating itself. I populate the string grid through code initially on FormShow and it appears perfectly OK if I have FixedRows := 0;
If I have FixedRows := 1; then it mainly duplicates the fixed row but you cannot access the row.
It redraws/repaints itself correctly under the following conditions :
a) You edit the grid and tab off the first row which the user can select (3rd physical row), 1st row is Fixed, 2nd row is a duplicate of 1st and 3rd is the first scrollable ie row 1.
b) You have horizontal scrolling enabled and you scroll to the right.
I have 5 grids on 3 tabsheets. 2 have FixedRows := 0; and give me no problem. The other 3 have FixedRows := 1; and the problem appears to be when the StringGrid container has focus.
Example : I leave the form in design mode on tabsheet1, the grid on this tabsheet duplicates the top row. I look at the grids on tabsheets 2 and 3 and they appear OK. Then on Tabsheet 2 I do something to cause the grid to be rebuilt by my code and then this grid will now duplicate the top, even though it ran the same routine as it did on Formshow at the start, the only difference is the tabsheet containing the grid now is visible.
Answer : Set Row = 1; and NOT Row = 0;