How can I determine the new row or column id after the user has dragged the rows/columns?

Here are some steps:

a) Add an user attribute. See gridsvw5.cpp in gridapp how to add a user attribute.

    Also, add an array

   CDWordArray m_awOriginalCol;

b) At initialization time (in OnInitialUpdate), you assign the column id to this user attribute, e.g.

   for (ROWCOL nCol = 0; nCol < nCount; nCol++)
   {
   wsprintf(sz, _T("%d"), nCol);
SetStyleRange(CGXRange().SetCols(nCol), CGXStyle().SetUserAttribute(IDS_UA_COLID, sz));
   }

c) Next, you override StoreMoveCols and StoreRemoveCols. In your overrides you call the
   base class version and after that you execute a line like the following

for (ROWCOL nCol = 0; nCol < nCount; nCol++)
{
   CGXStyle style;
   GetStyleRowCol(0, nCol, style, gxCopy, -1);
   m_awOriginalCol[atoi(style.GetUserAttribute(IDS_UA_COLID))] = nCol;
}

(You might also use SetItemDataPtr and use type conversion to an integer instead of using a user attribute).

d) Now, whenever you want to access the original column you may call

   if (m_awOriginalCol.GetSize() > nCol && m_awOriginalCol[nCol] > 0)
      // columns have been rearranged, get original column
      nCol = m_awOriginalCol[nCol];
   GetStyleRowCol(nRow, nCol, ....);