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. How can i Add a set of integers to my ComboBox

How can i Add a set of integers to my ComboBox

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

    hi, I've added a set of strings(from Database) to my combo box using membervariable.AddString(CString) Now,How can i add a set of integers to my combo box. Can any one tell mi a solution for this...with a clear example(as i'm a beginner). if so please tell me how to add the floats to the same.. thank you in advance..........

    M 1 Reply Last reply
    0
    • S saravana001

      hi, I've added a set of strings(from Database) to my combo box using membervariable.AddString(CString) Now,How can i add a set of integers to my combo box. Can any one tell mi a solution for this...with a clear example(as i'm a beginner). if so please tell me how to add the floats to the same.. thank you in advance..........

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      You can convert your numeric types to strings...

      int i = 42;
      CString str;
      str.Format(_T("%d"), i);
      m_combobox.AddString(str);

      double d = 1.23456;
      CString str;
      str.Format(_T("%.3f"), d); // rounded to 3 decimal places
      m_combobox.AddString(str);

      Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      C 1 Reply Last reply
      0
      • M Mark Salsbery

        You can convert your numeric types to strings...

        int i = 42;
        CString str;
        str.Format(_T("%d"), i);
        m_combobox.AddString(str);

        double d = 1.23456;
        CString str;
        str.Format(_T("%.3f"), d); // rounded to 3 decimal places
        m_combobox.AddString(str);

        Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        C Offline
        C Offline
        chandu004
        wrote on last edited by
        #3

        hai mark, even i wanted to suggest the same,but before hitting reply, i saw your name ,got diverted towards your post, and dropped my idea. your post is more descriptive.

        Mark Salsbery wrote:

        str.Format(_T("%d"), i);

        can you please explain me why you have used _T there. thank you.

        Suggestion to the members: prefix your main thread subject with [SOLVED] if it is solved. chandu.

        M 2 Replies Last reply
        0
        • C chandu004

          hai mark, even i wanted to suggest the same,but before hitting reply, i saw your name ,got diverted towards your post, and dropped my idea. your post is more descriptive.

          Mark Salsbery wrote:

          str.Format(_T("%d"), i);

          can you please explain me why you have used _T there. thank you.

          Suggestion to the members: prefix your main thread subject with [SOLVED] if it is solved. chandu.

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          chandu004 wrote:

          can you please explain me why you have used _T there.

          I use the generic text mappings everywhere. In this case, I'm using a CString, which is a generic type (unlike CStringA and CStringW).  CString::Format() takes a PCXSTR as its first argument so I use _T() to get that type. This will compile on both Unicode and non-Unicode builds... that's the whole idea :) Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          1 Reply Last reply
          0
          • C chandu004

            hai mark, even i wanted to suggest the same,but before hitting reply, i saw your name ,got diverted towards your post, and dropped my idea. your post is more descriptive.

            Mark Salsbery wrote:

            str.Format(_T("%d"), i);

            can you please explain me why you have used _T there. thank you.

            Suggestion to the members: prefix your main thread subject with [SOLVED] if it is solved. chandu.

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            Some reference material... Using Generic-Text Mappings (CRT)[^]

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            C 1 Reply Last reply
            0
            • M Mark Salsbery

              Some reference material... Using Generic-Text Mappings (CRT)[^]

              Mark Salsbery Microsoft MVP - Visual C++ :java:

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

              thanks mark. i feel that, observing your posts one day is equalent to reading one book per day.:) :rolleyes:

              Suggestion to the members: prefix your main thread subject with [SOLVED] if it is solved. chandu.

              H 1 Reply Last reply
              0
              • C chandu004

                thanks mark. i feel that, observing your posts one day is equalent to reading one book per day.:) :rolleyes:

                Suggestion to the members: prefix your main thread subject with [SOLVED] if it is solved. chandu.

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

                Of course sometime forums are better than books like this forum.

                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