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. String Problem

String Problem

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
9 Posts 4 Posters 1 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.
  • H Offline
    H Offline
    Hari_16
    wrote on last edited by
    #1

    Hi All, I am filling numbers in a listBox. for(int i =;i<20;i++) { CString string; string.Format(i); ListBox.Addstring(string); } the output is like 0 1 10 11 12 .. .. .. .. 19 2 3 4 5 6 7 8 9 Can anypne tell how to get the numbers in order and not like this..

    J D 2 Replies Last reply
    0
    • H Hari_16

      Hi All, I am filling numbers in a listBox. for(int i =;i<20;i++) { CString string; string.Format(i); ListBox.Addstring(string); } the output is like 0 1 10 11 12 .. .. .. .. 19 2 3 4 5 6 7 8 9 Can anypne tell how to get the numbers in order and not like this..

      J Offline
      J Offline
      Jijo Raj
      wrote on last edited by
      #2

      Hi hraman, Remove the 'sort' style of your list box and everything will be alright. Best Regards, Jijo.

      _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

      H 1 Reply Last reply
      0
      • J Jijo Raj

        Hi hraman, Remove the 'sort' style of your list box and everything will be alright. Best Regards, Jijo.

        _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

        H Offline
        H Offline
        Hari_16
        wrote on last edited by
        #3

        Hi I used a while loop and i am having the same problem while(i<20) { CString string; string.Format(i); ListBox.Addstring(string); ++i; } Can u please be bit detailed on what u mean by Sort? Thanks!!!!

        CPalliniC 1 Reply Last reply
        0
        • H Hari_16

          Hi I used a while loop and i am having the same problem while(i<20) { CString string; string.Format(i); ListBox.Addstring(string); ++i; } Can u please be bit detailed on what u mean by Sort? Thanks!!!!

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          By default, Visual Studio sets the LBS_SORT style (forcing alphabetic sort) when adds a Listbox control to your window. To remove it, in the Resource View pane, select the Listbox and then set the Sort property to False. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          In testa che avete, signor di Ceprano?

          H 1 Reply Last reply
          0
          • CPalliniC CPallini

            By default, Visual Studio sets the LBS_SORT style (forcing alphabetic sort) when adds a Listbox control to your window. To remove it, in the Resource View pane, select the Listbox and then set the Sort property to False. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            H Offline
            H Offline
            Hari_16
            wrote on last edited by
            #5

            Thanks a lot .. i changed it and now its working fine Thanks

            CPalliniC 1 Reply Last reply
            0
            • H Hari_16

              Thanks a lot .. i changed it and now its working fine Thanks

              CPalliniC Offline
              CPalliniC Offline
              CPallini
              wrote on last edited by
              #6

              You are welcome. BTW: I really don't know why they think alphabetic sort should be the default. :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              In testa che avete, signor di Ceprano?

              D 1 Reply Last reply
              0
              • CPalliniC CPallini

                You are welcome. BTW: I really don't know why they think alphabetic sort should be the default. :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

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

                CPallini wrote:

                BTW: I really don't know why they think alphabetic sort should be the default.

                As opposed to what?

                "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                CPalliniC 1 Reply Last reply
                0
                • H Hari_16

                  Hi All, I am filling numbers in a listBox. for(int i =;i<20;i++) { CString string; string.Format(i); ListBox.Addstring(string); } the output is like 0 1 10 11 12 .. .. .. .. 19 2 3 4 5 6 7 8 9 Can anypne tell how to get the numbers in order and not like this..

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

                  Another approach would be to left-pad the numbers with a 0. That may go against your design, however.

                  "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  1 Reply Last reply
                  0
                  • D David Crow

                    CPallini wrote:

                    BTW: I really don't know why they think alphabetic sort should be the default.

                    As opposed to what?

                    "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                    CPalliniC Offline
                    CPalliniC Offline
                    CPallini
                    wrote on last edited by
                    #9

                    No sort. :)

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    In testa che avete, signor di Ceprano?

                    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