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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CString.Format - new line?

CString.Format - new line?

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 3 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.
  • O Offline
    O Offline
    Oliver123
    wrote on last edited by
    #1

    I want to display each of the below variables in a separate line in a list box. I know I can use a separate InsertString for each one. But I wonder if there is a format command I can put in the ComplMessage.Format that will cause each one to go to a new line. I have looked at the format directives for sprintf, but don't see anything obvious. But sometimes it just isn't obvious. Any ideas? Thanks. ComplMessage.Format("%d %s %s %c %d@%.4s %8s %d/%d %7s %d-%s", orderDetail.XrefP, orderDetail.ContractName, orderDetail.ContractDate, orderDetail.BuyOrSell, orderDetail.Lots, orderDetail.Price, orderDetail.OrderID, orderDetail.AmountFilled, orderDetail.NoOfFills, orderDetail.AveragePrice, orderDetail.Status, StatLine); pListBox->InsertString(0,ComplMessage);

    L D 2 Replies Last reply
    0
    • O Oliver123

      I want to display each of the below variables in a separate line in a list box. I know I can use a separate InsertString for each one. But I wonder if there is a format command I can put in the ComplMessage.Format that will cause each one to go to a new line. I have looked at the format directives for sprintf, but don't see anything obvious. But sometimes it just isn't obvious. Any ideas? Thanks. ComplMessage.Format("%d %s %s %c %d@%.4s %8s %d/%d %7s %d-%s", orderDetail.XrefP, orderDetail.ContractName, orderDetail.ContractDate, orderDetail.BuyOrSell, orderDetail.Lots, orderDetail.Price, orderDetail.OrderID, orderDetail.AmountFilled, orderDetail.NoOfFills, orderDetail.AveragePrice, orderDetail.Status, StatLine); pListBox->InsertString(0,ComplMessage);

      L Offline
      L Offline
      Le Thanh Cong
      wrote on last edited by
      #2

      You can use edit box with multi line to instead listbox

      ----------------- Best Regards, Le Thanh Cong

      1 Reply Last reply
      0
      • O Oliver123

        I want to display each of the below variables in a separate line in a list box. I know I can use a separate InsertString for each one. But I wonder if there is a format command I can put in the ComplMessage.Format that will cause each one to go to a new line. I have looked at the format directives for sprintf, but don't see anything obvious. But sometimes it just isn't obvious. Any ideas? Thanks. ComplMessage.Format("%d %s %s %c %d@%.4s %8s %d/%d %7s %d-%s", orderDetail.XrefP, orderDetail.ContractName, orderDetail.ContractDate, orderDetail.BuyOrSell, orderDetail.Lots, orderDetail.Price, orderDetail.OrderID, orderDetail.AmountFilled, orderDetail.NoOfFills, orderDetail.AveragePrice, orderDetail.Status, StatLine); pListBox->InsertString(0,ComplMessage);

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

        Oliver123 wrote:

        I have looked at the format directives for sprintf, but don't see anything obvious.

        Any reason why you don't use \n in the format specifier?


        "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

        "Judge not by the eye but by the heart." - Native American Proverb

        O 1 Reply Last reply
        0
        • D David Crow

          Oliver123 wrote:

          I have looked at the format directives for sprintf, but don't see anything obvious.

          Any reason why you don't use \n in the format specifier?


          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

          "Judge not by the eye but by the heart." - Native American Proverb

          O Offline
          O Offline
          Oliver123
          wrote on last edited by
          #4

          I tried that. Also tried \n\r. \n yields a bold vertical bar in the resulting single line of text. \n\r yields two bold vertical bars.

          D 1 Reply Last reply
          0
          • O Oliver123

            I tried that. Also tried \n\r. \n yields a bold vertical bar in the resulting single line of text. \n\r yields two bold vertical bars.

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

            Of course it does. What else would you expect it to display since a list control is not meant for multiple lines. If you must have multiple lines, use an edit control with the ES_MULTILINE style.


            "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

            "Judge not by the eye but by the heart." - Native American Proverb

            O 1 Reply Last reply
            0
            • D David Crow

              Of course it does. What else would you expect it to display since a list control is not meant for multiple lines. If you must have multiple lines, use an edit control with the ES_MULTILINE style.


              "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

              "Judge not by the eye but by the heart." - Native American Proverb

              O Offline
              O Offline
              Oliver123
              wrote on last edited by
              #6

              I guess I have been using the wrong tool for the job. The edit control works much better. Thanks.

              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