Position cursor on last item in CListCtrl (reportmode)
-
Hello all, I'm having troubles positioning my current record indicator programmicaly on the last record. Let's say I have a CListCtrl in report mode, Filled with some records. I have a button which inserts a new record in the list, and I want to position the record indicator (that blue line) on the newly inserted record. I tried:
m_cListCtrl.EnsureVisible(m_cListCtrl.GetItemCount()-1, FALSE); m_cListCtrl.SetItemState(m_cListCtrl.GetItemCount()-1, LVIS_SELECTED, LVIS_SELECTED); m_cListCtrl.SetSelectionMark(m_cListCtrl.GetItemCount()-1);
which shows me the record, the blue line is in the correct position, but my focus isn't. When I press Up, the record indicator jumps back 2 positions. What is the correct way to do this positioning? -
Hello all, I'm having troubles positioning my current record indicator programmicaly on the last record. Let's say I have a CListCtrl in report mode, Filled with some records. I have a button which inserts a new record in the list, and I want to position the record indicator (that blue line) on the newly inserted record. I tried:
m_cListCtrl.EnsureVisible(m_cListCtrl.GetItemCount()-1, FALSE); m_cListCtrl.SetItemState(m_cListCtrl.GetItemCount()-1, LVIS_SELECTED, LVIS_SELECTED); m_cListCtrl.SetSelectionMark(m_cListCtrl.GetItemCount()-1);
which shows me the record, the blue line is in the correct position, but my focus isn't. When I press Up, the record indicator jumps back 2 positions. What is the correct way to do this positioning?Wim Jans wrote: m_cListCtrl.SetItemState(m_cListCtrl.GetItemCount()-1, LVIS_SELECTED, LVIS_SELECTED); How about:
m_cListCtrl.SetItemState(m_cListCtrl.GetItemCount()-1, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
-
Wim Jans wrote: m_cListCtrl.SetItemState(m_cListCtrl.GetItemCount()-1, LVIS_SELECTED, LVIS_SELECTED); How about:
m_cListCtrl.SetItemState(m_cListCtrl.GetItemCount()-1, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);