How can I enable dragging rows? I want that the user is able to move columns to a new position just the same way as this is possible with columns.
In your OnInitialUpdate routine, you should turn on the EnableMoveRows attribute. You should call EnableMoveRows after calling the base class OnInitialUpdate routine.
Example:
void CDaoqueryView::OnInitialUpdate()
{
...
// Attach the recordset object
SetRecordset(&pDoc->m_dynamicSet);
// standard initialization, will create other objects
// such as column names, widths, base styles, ...
CMyDaoRecordView::OnInitialUpdate();
GetParam()->EnableMoveRows(TRUE);
}
If you want to serialize reordered rows, you have to add code which serialize the row indexes in your documents Serialize() method.
Example:
void CDaoqueryDoc::Serialize(CArchive& ar)
{
...
if (ar.IsStoring())
{
// column settings, base styles
ar << m_pParam;
...
}
else
{
// column settings, base styles
ar >> m_pParam;
// Open recordset, ...
}
m_pParam->m_awRowIndex.Serialize(ar);
}