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. CListBox how to set single selection?

CListBox how to set single selection?

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutoriallearning
10 Posts 4 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.
  • R Offline
    R Offline
    Romiks
    wrote on last edited by
    #1

    Hi all, I have CListBox with selection set to Extended in resource editor. In my prog I need to set selection to single. Please point me, how can I do this?

    D 1 Reply Last reply
    0
    • R Romiks

      Hi all, I have CListBox with selection set to Extended in resource editor. In my prog I need to set selection to single. Please point me, how can I do this?

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

      Remove the LBS_MULTIPLESEL style.


      "A good athlete is the result of a good and worthy opponent." - David Crow

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      L R 2 Replies Last reply
      0
      • D David Crow

        Remove the LBS_MULTIPLESEL style.


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        L Offline
        L Offline
        led mike
        wrote on last edited by
        #3

        * waiting for the other shoe *

        1 Reply Last reply
        0
        • D David Crow

          Remove the LBS_MULTIPLESEL style.


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          R Offline
          R Offline
          Romiks
          wrote on last edited by
          #4

          This one doesn't work m_listFiles.ModifyStyle( 0, LBS_EXTENDEDSEL | LBS_MULTIPLESEL ); :(

          D 1 Reply Last reply
          0
          • R Romiks

            This one doesn't work m_listFiles.ModifyStyle( 0, LBS_EXTENDEDSEL | LBS_MULTIPLESEL ); :(

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

            Romiks wrote:

            This one doesn't work

            How are you verifying this? After this runs, you should be able to use Spy++ to see the list of styles that particular control has. You should see LBS_EXTENDEDSEL and LBS_MULTIPLESEL in that list. Of course if you want the control to be single-select, I doubt that adding the LBS_MULTIPLESEL style will work. ;)


            "A good athlete is the result of a good and worthy opponent." - David Crow

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            R 1 Reply Last reply
            0
            • D David Crow

              Romiks wrote:

              This one doesn't work

              How are you verifying this? After this runs, you should be able to use Spy++ to see the list of styles that particular control has. You should see LBS_EXTENDEDSEL and LBS_MULTIPLESEL in that list. Of course if you want the control to be single-select, I doubt that adding the LBS_MULTIPLESEL style will work. ;)


              "A good athlete is the result of a good and worthy opponent." - David Crow

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              R Offline
              R Offline
              Romiks
              wrote on last edited by
              #6

              Ok, I did single select ListBox and trying to add styles like this: m_listFiles.ModifyStyle( 0, LBS_EXTENDEDSEL | LBS_MULTIPLESEL ); m_listFiles.UpdateWindow(); SPY shows me LBS_EXTENDEDSEL and LBS_MULTIPLESEL styles present, but actually the list is single select :confused:

              D 1 Reply Last reply
              0
              • R Romiks

                Ok, I did single select ListBox and trying to add styles like this: m_listFiles.ModifyStyle( 0, LBS_EXTENDEDSEL | LBS_MULTIPLESEL ); m_listFiles.UpdateWindow(); SPY shows me LBS_EXTENDEDSEL and LBS_MULTIPLESEL styles present, but actually the list is single select :confused:

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

                Then you may have found a style that cannot be altered at run-time. There are several.


                "A good athlete is the result of a good and worthy opponent." - David Crow

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                N R 2 Replies Last reply
                0
                • D David Crow

                  Then you may have found a style that cannot be altered at run-time. There are several.


                  "A good athlete is the result of a good and worthy opponent." - David Crow

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  N Offline
                  N Offline
                  Nelek
                  wrote on last edited by
                  #8

                  What about not using ModifyStyle? I mean get the style, style = style | ~NonDesiredMode and SetStyle (style) another time... can it work?

                  Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?

                  D 1 Reply Last reply
                  0
                  • D David Crow

                    Then you may have found a style that cannot be altered at run-time. There are several.


                    "A good athlete is the result of a good and worthy opponent." - David Crow

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    R Offline
                    R Offline
                    Romiks
                    wrote on last edited by
                    #9

                    You are quite right, thanks I'll try to find another way.

                    1 Reply Last reply
                    0
                    • N Nelek

                      What about not using ModifyStyle? I mean get the style, style = style | ~NonDesiredMode and SetStyle (style) another time... can it work?

                      Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?

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

                      Nelek wrote:

                      can it work?

                      Why not try it and see?


                      "A good athlete is the result of a good and worthy opponent." - David Crow

                      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                      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