delphi - How do I delete a TStringGrid row? -


i have tstringgrid, , want delete selected row. basic things i've tried delete last row. how delete arbitrary row?

if code you've tried deletes last row, you're decrementing rowcount property. indeed makes modifications on end of list of rows. in mind, write code ensure row no longer want 1 @ end, , then delete last row. (the direct way move row, , there's moverow method, it's protected. if wish call protected methods, though, may call deleterow instead.)

using public , published members, it's possible write loop deletes arbitrary row. example, here's code inspired scalabium software's faq on topic:

procedure deleterow(grid: tstringgrid; arow: integer); var   i: integer; begin   := arow grid.rowcount - 2     grid.rows[i].assign(grid.rows[i + 1]);   grid.rowcount := grid.rowcount - 1; end; 

it copies contents of each row below 1 wish delete row above. @ end of loop, row wish delete has been overwritten (by row below it) , there 2 copies of final row. deletes final row.

to delete current row of grid, call function this:

deleterow(grid, grid.row); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -