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 to format numbers with dollar sign in a cell for a CListCtrl

how to format numbers with dollar sign in a cell for a CListCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
6 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.
  • M Offline
    M Offline
    manchukuo
    wrote on last edited by
    #1

    Hi guys what i want to do is to show some data in a ClistCtrl column like the following: ________________________________________ stuff |$ 434.55 | ---------------------------------------- stuff2|$ 22,333.55 | ---------------------------------------- stuff2|$ 86.55 | ---------------------------------------- have the dollar sign at the left side, and the number be always at the right side, can someone point me how to do this?? maybe calculing the size of the text and compare it to the cell rect and to some math there? but how how do you get the size of the text?, i remember seeing a function for that but i don't remember the name of it, or if you have an another suggestion please

    CPalliniC D PJ ArendsP 3 Replies Last reply
    0
    • M manchukuo

      Hi guys what i want to do is to show some data in a ClistCtrl column like the following: ________________________________________ stuff |$ 434.55 | ---------------------------------------- stuff2|$ 22,333.55 | ---------------------------------------- stuff2|$ 86.55 | ---------------------------------------- have the dollar sign at the left side, and the number be always at the right side, can someone point me how to do this?? maybe calculing the size of the text and compare it to the cell rect and to some math there? but how how do you get the size of the text?, i remember seeing a function for that but i don't remember the name of it, or if you have an another suggestion please

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

      manchukuo wrote:

      but how how do you get the size of the text?

      GetTextExtentPoint32[^]. :)

      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?

      M 1 Reply Last reply
      0
      • CPalliniC CPallini

        manchukuo wrote:

        but how how do you get the size of the text?

        GetTextExtentPoint32[^]. :)

        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]

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

        Thanks CPallini that is the one i was looking for, so there is no easy way to achieve what i need? or i will have to do all the mungle jumble that i already wrote?

        CPalliniC 1 Reply Last reply
        0
        • M manchukuo

          Thanks CPallini that is the one i was looking for, so there is no easy way to achieve what i need? or i will have to do all the mungle jumble that i already wrote?

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

          I would go with the mungle jumble (i.e. sorry, I don't know an alternative). :)

          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
          • M manchukuo

            Hi guys what i want to do is to show some data in a ClistCtrl column like the following: ________________________________________ stuff |$ 434.55 | ---------------------------------------- stuff2|$ 22,333.55 | ---------------------------------------- stuff2|$ 86.55 | ---------------------------------------- have the dollar sign at the left side, and the number be always at the right side, can someone point me how to do this?? maybe calculing the size of the text and compare it to the cell rect and to some math there? but how how do you get the size of the text?, i remember seeing a function for that but i don't remember the name of it, or if you have an another suggestion please

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

            Have you tried GetNumberFormat() to properly insert the commas and decimal? Then just prefix a '$' and a number of spaces to the resulting string.

            "One man's wage rise is another man's price increase." - Harold Wilson

            "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

            "Man who follows car will be exhausted." - Confucius

            1 Reply Last reply
            0
            • M manchukuo

              Hi guys what i want to do is to show some data in a ClistCtrl column like the following: ________________________________________ stuff |$ 434.55 | ---------------------------------------- stuff2|$ 22,333.55 | ---------------------------------------- stuff2|$ 86.55 | ---------------------------------------- have the dollar sign at the left side, and the number be always at the right side, can someone point me how to do this?? maybe calculing the size of the text and compare it to the cell rect and to some math there? but how how do you get the size of the text?, i remember seeing a function for that but i don't remember the name of it, or if you have an another suggestion please

              PJ ArendsP Offline
              PJ ArendsP Offline
              PJ Arends
              wrote on last edited by
              #6

              Have you tried GetCurrencyFormat[^]?


              You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!

              Within you lies the power for good; Use it!

              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