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. mark a row as selected in a list control

mark a row as selected in a list control

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 3 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.
  • Q Offline
    Q Offline
    Qadddd
    wrote on last edited by
    #1

    Hello guys, I am trying to play with a List control (report style) and I would like to do the following thing : I select a row in my list (that becomes highlighted) and, thanks to 2 buttons (UP and Down), I exchange the place of this raw with the previous one (UP) to make it go to the top of the list or with the next one (DOWN) to make it go to the bottom of the list. After a click on one of my buttons, I exchange the 2 rows, my row is no more highlighted and I would like it to keep highlighted. I have tried to play with the SetItemState to set the focus and the selection bits to make it highlighted again but without success. So my question is : how do I give my row this selected aspect (highlight) by program? Thanks in advance DD

    M P 2 Replies Last reply
    0
    • Q Qadddd

      Hello guys, I am trying to play with a List control (report style) and I would like to do the following thing : I select a row in my list (that becomes highlighted) and, thanks to 2 buttons (UP and Down), I exchange the place of this raw with the previous one (UP) to make it go to the top of the list or with the next one (DOWN) to make it go to the bottom of the list. After a click on one of my buttons, I exchange the 2 rows, my row is no more highlighted and I would like it to keep highlighted. I have tried to play with the SetItemState to set the focus and the selection bits to make it highlighted again but without success. So my question is : how do I give my row this selected aspect (highlight) by program? Thanks in advance DD

      M Offline
      M Offline
      Max Santos
      wrote on last edited by
      #2

      m_List.SetItemState(index,LVIS_SELECTED, LVIS_SELECTED); this will do

      Q 1 Reply Last reply
      0
      • M Max Santos

        m_List.SetItemState(index,LVIS_SELECTED, LVIS_SELECTED); this will do

        Q Offline
        Q Offline
        Qadddd
        wrote on last edited by
        #3

        hello, that's exactly what I tried (except if my memory fails), LVIS_SELECTED as value and as mask ... I also tried LVIS_FOCUSED ... but without success. I will doublecheck tonite. This should immediatly highlight the item, no need of redraw or something else ? Thanks for the answer DD

        1 Reply Last reply
        0
        • Q Qadddd

          Hello guys, I am trying to play with a List control (report style) and I would like to do the following thing : I select a row in my list (that becomes highlighted) and, thanks to 2 buttons (UP and Down), I exchange the place of this raw with the previous one (UP) to make it go to the top of the list or with the next one (DOWN) to make it go to the bottom of the list. After a click on one of my buttons, I exchange the 2 rows, my row is no more highlighted and I would like it to keep highlighted. I have tried to play with the SetItemState to set the focus and the selection bits to make it highlighted again but without success. So my question is : how do I give my row this selected aspect (highlight) by program? Thanks in advance DD

          P Offline
          P Offline
          P Rex
          wrote on last edited by
          #4

          Have you tried LVS_SHOWSELALWAYS Style? It always show the selection, even if the control does not have the focus. Use SetExtendedStyle() to set the LVS_SHOWSELALWAYS. P.

          Q 2 Replies Last reply
          0
          • P P Rex

            Have you tried LVS_SHOWSELALWAYS Style? It always show the selection, even if the control does not have the focus. Use SetExtendedStyle() to set the LVS_SHOWSELALWAYS. P.

            Q Offline
            Q Offline
            Qadddd
            wrote on last edited by
            #5

            good idea !! it is true that the list lost control because I clicked the button ... Thanks for answer DD

            1 Reply Last reply
            0
            • P P Rex

              Have you tried LVS_SHOWSELALWAYS Style? It always show the selection, even if the control does not have the focus. Use SetExtendedStyle() to set the LVS_SHOWSELALWAYS. P.

              Q Offline
              Q Offline
              Qadddd
              wrote on last edited by
              #6

              Strange .. it doesn't work. In fact, if I add the LVS_SHOWSELALWAYS option, the control works as if there was a hot item, the fact to keep the mouse pointer over an item selects it, but as soon as I click my buttons, the highlight desappears ... Very strange ... Could it be a kind of icompatibility with another option? I also use : LVS_EX_CHECKBOXES, LVS_EX_FULLROWSELECT, LVS_EX_GRIDLINES, LVS_EX_INFOTIP, LVS_REPORT I really don't understand what happens .. Thanks in advance for help DD

              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