Hello all,

I am creating my own custom grid control and I need some ideas. I have created grids in the past that store all the cells in a big array and everytime that a column or row is added/removed/moved I have to create a new array (smaller or bigger than the original) loop through the original and copy its contents to the new array, deallocate the memory used by the original array and then set the original to the new. Does that make sense? Here's an example:
Code:
void AddCol()
{
  CELLSTRUCT* pTemp = new CELLSTRUCT[(m_nColCount + 1) * m_nRowCount];

  if (m_pCells)
  {
    for (int row = 0; row < m_nRowCount; row++)
    {
      for (int col = 0; col < m_nColCount; col++)
      {
        pTemp[col + (row * m_nColCount)] = m_pCells[col + (row * m_nColCount)];
      }
    }
    delete[] m_pCells;
  }

  m_nColCount++;
  m_pCells = pTemp;
}
While this method definitely works, it seems a bit ineffecient. What I want to know is:
Does anyone else know a better, more effecient method of maintaining grid data? Anyone know how some of the more advanced grids work, like the grid SQL Server Enterprise Manager uses? Thanks for any help/ideas...

Rippin