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. listCtrl - moving through selected lines

listCtrl - moving through selected lines

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 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.
  • E Offline
    E Offline
    ensger
    wrote on last edited by
    #1

    Hello, Moving through selected lines of a listCtrl from first to last is easy (GetFirstSelectedItemPosition - GetNextSelectedItem). But does anyone know an easy way to move from the last selected line to the first?? Thanks, Gerhard

    D C 2 Replies Last reply
    0
    • E ensger

      Hello, Moving through selected lines of a listCtrl from first to last is easy (GetFirstSelectedItemPosition - GetNextSelectedItem). But does anyone know an easy way to move from the last selected line to the first?? Thanks, Gerhard

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

      With the last item as the current one, I think you can use GetNextItem(-1, LVNI_SELECTED | LVNI_ABOVE) for this. Why do you need this functionality?


      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

      "Judge not by the eye but by the heart." - Native American Proverb

      E 1 Reply Last reply
      0
      • E ensger

        Hello, Moving through selected lines of a listCtrl from first to last is easy (GetFirstSelectedItemPosition - GetNextSelectedItem). But does anyone know an easy way to move from the last selected line to the first?? Thanks, Gerhard

        C Offline
        C Offline
        Chris Meech
        wrote on last edited by
        #3

        If it worked the first time, wouldn't GetFirstSelectedItemPosition work again? :confused:

        Chris Meech I am Canadian. [heard in a local bar] I agree with you that my argument is useless. [Red Stateler] Hey, I am part of a special bread, we are called smart people [Captain See Sharp] The zen of the soapbox is hard to attain...[Jörgen Sigvardsson] I wish I could remember what it was like to only have a short term memory.[David Kentley]

        E 1 Reply Last reply
        0
        • C Chris Meech

          If it worked the first time, wouldn't GetFirstSelectedItemPosition work again? :confused:

          Chris Meech I am Canadian. [heard in a local bar] I agree with you that my argument is useless. [Red Stateler] Hey, I am part of a special bread, we are called smart people [Captain See Sharp] The zen of the soapbox is hard to attain...[Jörgen Sigvardsson] I wish I could remember what it was like to only have a short term memory.[David Kentley]

          E Offline
          E Offline
          ensger
          wrote on last edited by
          #4

          I think so, but I need a loop moving through all selected lines from the last to the first. I admit, my question was not exact enough:sigh: Thank's, Gerhard

          1 Reply Last reply
          0
          • D David Crow

            With the last item as the current one, I think you can use GetNextItem(-1, LVNI_SELECTED | LVNI_ABOVE) for this. Why do you need this functionality?


            "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

            "Judge not by the eye but by the heart." - Native American Proverb

            E Offline
            E Offline
            ensger
            wrote on last edited by
            #5

            Tried the following: POSITION pos = listCtrl.GetFirstSelectedItemPosition(); if (pos) line = listCtrl.GetNextSelectedItem(pos); while (line != -1) { lineprev = line; line = listCtrl.GetNextSelectedItem(pos); }; line = lineprev; while (line != -1) { ........ line = listCtrl.GetNextItem(-1, LVNI_SELECTED | LVNI_ABOVE); }; But it doesn't work. Line is -1 after the first call of GetNextItem. But it's late here, maybe there's an obvious error:^) Thank's, Gerhard

            D 1 Reply Last reply
            0
            • E ensger

              Tried the following: POSITION pos = listCtrl.GetFirstSelectedItemPosition(); if (pos) line = listCtrl.GetNextSelectedItem(pos); while (line != -1) { lineprev = line; line = listCtrl.GetNextSelectedItem(pos); }; line = lineprev; while (line != -1) { ........ line = listCtrl.GetNextItem(-1, LVNI_SELECTED | LVNI_ABOVE); }; But it doesn't work. Line is -1 after the first call of GetNextItem. But it's late here, maybe there's an obvious error:^) Thank's, Gerhard

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

              ensger wrote:

              line = listCtrl.GetNextItem(-1, LVNI_SELECTED | LVNI_ABOVE);

              Did you consider changing the -1 argument to some other value?


              "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

              "Judge not by the eye but by the heart." - Native American Proverb

              E 1 Reply Last reply
              0
              • D David Crow

                ensger wrote:

                line = listCtrl.GetNextItem(-1, LVNI_SELECTED | LVNI_ABOVE);

                Did you consider changing the -1 argument to some other value?


                "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                "Judge not by the eye but by the heart." - Native American Proverb

                E Offline
                E Offline
                ensger
                wrote on last edited by
                #7

                Was not able to do so last night. Today I tried: line = listCtrl.GetNextItem(line, LVNI_SELECTED | LVNI_ABOVE); and it works;) Thank's for your help, Gerhard

                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