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. CListCtrl set multiselection

CListCtrl set multiselection

Scheduled Pinned Locked Moved C / C++ / MFC
questioncsharpc++visual-studiotutorial
6 Posts 3 Posters 5 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.
  • Z Offline
    Z Offline
    Zizilamoroso
    wrote on last edited by
    #1

    I've already got a multiselection CListCtrl in my application. How can I set the selection through code (example: multiselect rows 1,2 and 5)?
    [VISUAL STUDIO 6.0] [MFC] [WIN98/2]


    X| Bluute tette! X|

    K 1 Reply Last reply
    0
    • Z Zizilamoroso

      I've already got a multiselection CListCtrl in my application. How can I set the selection through code (example: multiselect rows 1,2 and 5)?
      [VISUAL STUDIO 6.0] [MFC] [WIN98/2]


      X| Bluute tette! X|

      K Offline
      K Offline
      KaRl
      wrote on last edited by
      #2

      TRy CListCtrl::SetItemState, with SetItemState(nMyIndex, LVIS_SELECTED | LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED); with nMyIndex = 1, 2 and 5

      Z 1 Reply Last reply
      0
      • K KaRl

        TRy CListCtrl::SetItemState, with SetItemState(nMyIndex, LVIS_SELECTED | LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED); with nMyIndex = 1, 2 and 5

        Z Offline
        Z Offline
        Zizilamoroso
        wrote on last edited by
        #3

        It works invisible, but it works :-) If the list looses it's focus, the selection is not shown on screen (but they remain selected though). How can I set the selection visible even when the focus is transfered to another control?
        [VISUAL STUDIO 6.0] [MFC] [WIN98/2]


        X| Bluute tette! X|

        Z 1 Reply Last reply
        0
        • Z Zizilamoroso

          It works invisible, but it works :-) If the list looses it's focus, the selection is not shown on screen (but they remain selected though). How can I set the selection visible even when the focus is transfered to another control?
          [VISUAL STUDIO 6.0] [MFC] [WIN98/2]


          X| Bluute tette! X|

          Z Offline
          Z Offline
          Zizilamoroso
          wrote on last edited by
          #4

          oeps ... :rolleyes: Show Selection Always!!! It's as easy.
          [VISUAL STUDIO 6.0] [MFC] [WIN98/2]


          X| Bluute tette! X|

          K J 2 Replies Last reply
          0
          • Z Zizilamoroso

            oeps ... :rolleyes: Show Selection Always!!! It's as easy.
            [VISUAL STUDIO 6.0] [MFC] [WIN98/2]


            X| Bluute tette! X|

            K Offline
            K Offline
            KaRl
            wrote on last edited by
            #5

            Yep, or programmatically with myListCtrl.ModifyStyle(0, LVS_SHOWSELALWAYS) HTH, K.

            1 Reply Last reply
            0
            • Z Zizilamoroso

              oeps ... :rolleyes: Show Selection Always!!! It's as easy.
              [VISUAL STUDIO 6.0] [MFC] [WIN98/2]


              X| Bluute tette! X|

              J Offline
              J Offline
              Jean Marc Molina
              wrote on last edited by
              #6

              Damn that's right ! I was wondering where it was... Just in the Styles property sheet of my control :). However I wonder how I can simply change the color to blue as if the list control still had the focus. Actually it greys the background. Earth > Europe > France > Lyon

              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