Board index » cppbuilder » TStringGrid - how to delete a row?
Hugh W Stewart
![]() CBuilder Developer |
Hugh W Stewart
![]() CBuilder Developer |
TStringGrid - how to delete a row?2004-01-03 12:21:59 AM cppbuilder91 Help! I want to delete a row from a TStringGrid. I tried ((TCustomGrid*)MyStringGrid)->DeleteRow(SelRow); where SelRow is an int. It tells me that DeleteRow is not accessible. Thanks for help Hugh |
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2004-01-03 02:13:07 AM
Re:TStringGrid - how to delete a row?
"Hugh W Stewart" < XXXX@XXXXX.COM >wrote in message
QuoteI want to delete a row from a TStringGrid. I tried to derive a new class and provide your own access to it, ie: class TMyStringGrid : public TStringGrid { public: __fastcall TMyStringGrid(TComponent *Owner) : TStringGrid(Owner) { } void __fastcall DeleteARow(int ARow) { TCustomGrid::DeleteRow(ARow); } }; Otherwise, you will just have to forget using the grid's DeleteRow() and just manipulate the rows manually, ie void __fastcall TForm1::DeleteRow(int Row) { if( Row>= StringGrid1->FixedRows ) { // move the content below the desired row up a row for(int x = Row; x < (StringGrid1->RowCount-1); ++x) StringGrid1->Rows[x]->Assign(StringGrid1->Rows[x+1]); // resize the grid to remove or clear the last row. // note - the grid does not support having 0 non-fixed rows if( StringGrid1->RowCount>(StringGrid1->FixedRows+1) ) StringGrid1->RowCount = (StringGrid1->RowCount - 1); else StringGrid1->Rows[StringGrid1->FixedRows]->Clear(); } } Gambit |
Hugh W Stewart
![]() CBuilder Developer |
2004-01-03 02:34:51 AM
Re:TStringGrid - how to delete a row?
Thank you - works like a charm!
Remy Lebeau (TeamB) wrote: Quote"Hugh W Stewart" < XXXX@XXXXX.COM >wrote in message {smallsort} |
Rodolfo Frino - Macrosoft
![]() CBuilder Developer |
2004-01-03 07:57:56 PM
Re:TStringGrid - how to delete a row?QuoteDeleteRow() is declared as protected in TCustomGrid, and TStringGrid does columns, creating a mess with the data stored in the StringGrid's cells. www.geocities.com/rodolfofrino/StringGridWithDeleteRow.html Rodolfo |
Rodolfo Frino - Macrosoft
![]() CBuilder Developer |
2004-01-03 08:00:14 PM
Re:TStringGrid - how to delete a row?
I wrote an article on an advance String Grid that supports both Col/Row
delete and Col/Row insert operations as well as SaveFile and ReadFile operations www.geocities.com/rodolfofrino/MicroStringGrid.html Rodolfo "Hugh W Stewart" < XXXX@XXXXX.COM >wrote in message QuoteHelp! |