Måske virker det her så... Det skulle vist være C++ nu :-) :
void __fastcall RemoveRow(
TStringGrid* StringGrid, int Index)
{
SendMessage(StringGrid->Handle,
WM_SETREDRAW, false, 0);
try {
const int row_count =
StringGrid->RowCount;
// (1) shift the contents of
// the trailing columns
for (int row = Index;
row < row_count - 1; ++row) {
StringGrid->Rows[row] =
StringGrid->Rows[row + 1];
}
// (2) remove the last column
StringGrid->RowCount = row_count -1;
}
catch (...) {
SendMessage(StringGrid->Handle,
WM_SETREDRAW, true, 0);
}
SendMessage(StringGrid->Handle,
WM_SETREDRAW, true, 0);
// update (repaint) the shifted cols
RECT R =
StringGrid->CellRect(0, Index);
InflateRect(&R, StringGrid->Width,
StringGrid->Height);
InvalidateRect(StringGrid->Handle,
&R, false);
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(StringGrid1->Selection.Left > 0)
RemoveRow(StringGrid1, StringGrid1->Selection.Left);
}
Fandt RemoveRow funktionen her:
http://www.cppbuilderdevjournal.com/articles/issues/0009/Working_with_string_grids.htm