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. Add items in list box

Add items in list box

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

    Hi All, I am creating a list box with multiple selection at a time. I would appreciate if someone let me know how to add items in LIST BOX using MFC. For example: I need to add USA, CANADA, MEXICO, ENGLAND, INDIA, CHINA in my list. How to add these itmes? Do I need to write code or just can do it other way? Thanks in advance MFC

    D M H 3 Replies Last reply
    0
    • C celllllllll

      Hi All, I am creating a list box with multiple selection at a time. I would appreciate if someone let me know how to add items in LIST BOX using MFC. For example: I need to add USA, CANADA, MEXICO, ENGLAND, INDIA, CHINA in my list. How to add these itmes? Do I need to write code or just can do it other way? Thanks in advance MFC

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

      Preeti9 wrote:

      I would appreciate if someone let me know how to add items in LIST BOX using MFC.

      Use CListBox::AddString() or CListBox::InsertString().


      "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

      "There is no death, only a change of worlds." - Native American Proverb

      C 1 Reply Last reply
      0
      • C celllllllll

        Hi All, I am creating a list box with multiple selection at a time. I would appreciate if someone let me know how to add items in LIST BOX using MFC. For example: I need to add USA, CANADA, MEXICO, ENGLAND, INDIA, CHINA in my list. How to add these itmes? Do I need to write code or just can do it other way? Thanks in advance MFC

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #3

        if the content is static ( will be filled once with constant values ) then, you can add them directly in the resource editor ( no code needed for that ). if the contenct is dynamic, you can use CListBox::AddString or CListBox::InsertString ( you need to code this ).


        Maximilien Lincourt Your Head A Splode - Strong Bad

        C 1 Reply Last reply
        0
        • D David Crow

          Preeti9 wrote:

          I would appreciate if someone let me know how to add items in LIST BOX using MFC.

          Use CListBox::AddString() or CListBox::InsertString().


          "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

          "There is no death, only a change of worlds." - Native American Proverb

          C Offline
          C Offline
          celllllllll
          wrote on last edited by
          #4

          Thanks for your help. Should it be like this: [\code] CListBox::AddString() { AddString("USA"); AddString("CANADA"); ..... .. } C++Prog

          D 1 Reply Last reply
          0
          • C celllllllll

            Thanks for your help. Should it be like this: [\code] CListBox::AddString() { AddString("USA"); AddString("CANADA"); ..... .. } C++Prog

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

            No. You will need a CListBox control variable (use ClassWizard for this), then call AddString() in the context of that variable.


            "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

            "There is no death, only a change of worlds." - Native American Proverb

            C 1 Reply Last reply
            0
            • M Maximilien

              if the content is static ( will be filled once with constant values ) then, you can add them directly in the resource editor ( no code needed for that ). if the contenct is dynamic, you can use CListBox::AddString or CListBox::InsertString ( you need to code this ).


              Maximilien Lincourt Your Head A Splode - Strong Bad

              C Offline
              C Offline
              celllllllll
              wrote on last edited by
              #6

              Thanks for your reply. Yes, the content is Static. Can you please give me some idea how to add this in resource editor. Thanks Once Again MFC

              D 1 Reply Last reply
              0
              • D David Crow

                No. You will need a CListBox control variable (use ClassWizard for this), then call AddString() in the context of that variable.


                "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                "There is no death, only a change of worlds." - Native American Proverb

                C Offline
                C Offline
                celllllllll
                wrote on last edited by
                #7

                O okay, Thanks...I got it. Thanks once again MFC

                1 Reply Last reply
                0
                • C celllllllll

                  Thanks for your reply. Yes, the content is Static. Can you please give me some idea how to add this in resource editor. Thanks Once Again MFC

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

                  Preeti9 wrote:

                  Yes, the content is Static. Can you please give me some idea how to add this in resource editor.

                  While it might be considered a neat idea, this solution has many drawbacks. In fact, it is only useful if the items in the control are language independent, and are insensitive to sorting.


                  "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                  "There is no death, only a change of worlds." - Native American Proverb

                  C 1 Reply Last reply
                  0
                  • D David Crow

                    Preeti9 wrote:

                    Yes, the content is Static. Can you please give me some idea how to add this in resource editor.

                    While it might be considered a neat idea, this solution has many drawbacks. In fact, it is only useful if the items in the control are language independent, and are insensitive to sorting.


                    "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                    "There is no death, only a change of worlds." - Native American Proverb

                    C Offline
                    C Offline
                    celllllllll
                    wrote on last edited by
                    #9

                    Hmmm, Thanks I got it. MFC

                    1 Reply Last reply
                    0
                    • C celllllllll

                      Hi All, I am creating a list box with multiple selection at a time. I would appreciate if someone let me know how to add items in LIST BOX using MFC. For example: I need to add USA, CANADA, MEXICO, ENGLAND, INDIA, CHINA in my list. How to add these itmes? Do I need to write code or just can do it other way? Thanks in advance MFC

                      H Offline
                      H Offline
                      Hamid Taebi
                      wrote on last edited by
                      #10

                      Like this CListBox m_List; m_List.AddString("123"); m_List.InsertString(1,"2323");

                      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