Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Position cursor on last item in CListCtrl (reportmode)

Position cursor on last item in CListCtrl (reportmode)

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wim Jans
    wrote on last edited by
    #1

    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?

    D 1 Reply Last reply
    0
    • W Wim Jans

      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?

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      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);

      W 1 Reply Last reply
      0
      • D David Crow

        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);

        W Offline
        W Offline
        Wim Jans
        wrote on last edited by
        #3

        Easy but efficient :) Thanks!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups