How do I delete a row in a cell grid?

Article ID: 891
Last updated: 05 Feb, 2008
Article ID: 891
Last updated: 05 Feb, 2008
Revision: 1
Views: 3073
Posted: 02 Feb, 1998
by Dean J.
Updated: 05 Feb, 2008
by Dean J.
Problem


How can I delete a row in a cell grid?



Action


Say, for example, you have a 20x20 cell grid and you would like to remove the 12th row.

You don't delete a row, per se. Instead, you change the number of rows for your grid and then remove the row (however it is represented) from the underlying data model.

Let's assume you have 20 rows and you would like to remove the 12th row when a button is pressed. In the event handler for the button, you would change the number of rows for the grid to be 19. Then you would have to modify the data model to remove the 12th row.

Here is an example of the first part...

--row_;
RowCollection rc = pCellGrid1.getRowCollection(); //this is where you change the number of rows
rc.setRows(row_);
pCellGrid1.refresh();

Then, depending on the collection type for the rows, you have to modify the data to remove that row.

For example, if the collection is an array, you move all the elements after the 12th location one spot over.

rem; //the row to be removed
for( i = rem; i <= row_; i++);
data[i]=data [i+1];
This article was:   Helpful | Not helpful
Report an issue
Article ID: 891
Last updated: 05 Feb, 2008
Revision: 1
Views: 3073
Posted: 02 Feb, 1998 by Dean J.
Updated: 05 Feb, 2008 by Dean J.

Others in this category