Copyright © 2010 Promsite. All Rights Reserved.
TStringGrid, часть I
Автор Деймон Чандлер перевод Виктор Алексеев aka prom
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
for(int i =0; i< StringGrid1 -> ColCount;i++)
for(int j =0; j< StringGrid1 -> RowCount;j++)
StringGrid1 -> Cells[i][j] = "asd";
}
//---------------------------------------------------------------------------
И результат на форме:
void __fastcall RemoveCol(TStringGrid* StringGrid, int Index)
{
SendMessage(StringGrid->Handle, WM_SETREDRAW, false, 0);
try {
const int col_count = StringGrid->ColCount;
// (шаг 1) сдвиг содержимого
// следующих колонок.
for (int col = Index;col < col_count - 1; ++col)
{
StringGrid->Cols[col] = StringGrid->Cols[col + 1];
}
// (шаг 2) удалить последнюю колонку.
StringGrid->ColCount = col_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);
}