2010. április 4., vasárnap
Insert a row in a TStringGrid at a certain position
Problem/Question/Abstract:
Is there a method to insert a row into a StringGrid or do I have to shuffle all higher rows up 1?
Answer:
TCustomGrid has a very useful but unfortunately protected method named MoveRow. You can get at it using the cracker class strategy:
type
TGridCracker = class(TCustomGrid);
{insert a line at row 5}
stringgrid1.rowcount := stringgrid1.rowcount + 1;
TGridCracker(stringgrid1).Moverow(stringgrid1.rowcount - 1, 5);
You first add a new empty line, then move it to the required position. This automatically moves all following lines one position down.
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése