I am generating a CListCtrl in Report view (MFC). It loads fine and I can reorder columns by dragging the headers. I've made it so clicking a column header deletes the column - again this works fine except for the first (leftmost) column. Here the header is deleted but the data underneath doesn't change - in fact the data from the last column is deleted:
Before :
Header1 Header2 Header3
Data1 Data2 Data3
After trying to delete first column :
Header2 Header3
Data1 Data2
Having created the columns to begin with, I'm setting up the rest of the table like this:
void MyClass::InsertItem(int x, int y, CString &str)
{
LVITEM lvi;
lvi.mask = LVIF_TEXT;
lvi.iItem = y;
lvi.iSubItem = x;
lvi.pszText = (LPTSTR)(LPCTSTR)(str);
int result;
if(x == 0) {
result = mCSVListCtrl.InsertItem(&lvi);
}
else {
result = mCSVListCtrl.SetItem(&lvi);
}
}
which seems to create the table OK. Then when a header is clicked:
void MyClass::OnLvnColumnclickList(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
mCSVListCtrl.DeleteColumn(pNMLV->iSubItem);// This IS getting zero
*pResult = 0;
}