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. CString Format Help

CString Format Help

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabasetutorial
3 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.
  • L Offline
    L Offline
    locoone
    wrote on last edited by
    #1

    i have a function all it does it print a CListCtrl to a text file but it is hard to read with all the data temp.Format("%s %10s %s\r\n", m_list.GetItemText(index, 0), "-", m_list.GetItemText(index, 2)); this works but gives a output like this some name here - text here longer name here - text here even longer name here - text here short name - text here what i want is some name here - text here longer name here - text here even longer name here - text here short name - text here well the "- text here" should be in a line but i cant get it right here either can anyone help me fix it ive see how to do it somewhere but cant find it now

    D S 2 Replies Last reply
    0
    • L locoone

      i have a function all it does it print a CListCtrl to a text file but it is hard to read with all the data temp.Format("%s %10s %s\r\n", m_list.GetItemText(index, 0), "-", m_list.GetItemText(index, 2)); this works but gives a output like this some name here - text here longer name here - text here even longer name here - text here short name - text here what i want is some name here - text here longer name here - text here even longer name here - text here short name - text here well the "- text here" should be in a line but i cant get it right here either can anyone help me fix it ive see how to do it somewhere but cant find it now

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

      locoone wrote:

      well the "- text here" should be in a line but i cant get it right here either can anyone help me fix it ive see how to do it somewhere but cant find it now

      Use the <pre> tags:

      some name here - text here
      longer name here - text here
      even longer name here - text here
      short name - text here

      Now if you want your code to produce this, try:

      temp.Format("%-28s - %s\r\n", m_list.GetItemText(index, 0), m_list.GetItemText(index, 2));

      "Love people and use things, not love things and use people." - Unknown

      "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

      1 Reply Last reply
      0
      • L locoone

        i have a function all it does it print a CListCtrl to a text file but it is hard to read with all the data temp.Format("%s %10s %s\r\n", m_list.GetItemText(index, 0), "-", m_list.GetItemText(index, 2)); this works but gives a output like this some name here - text here longer name here - text here even longer name here - text here short name - text here what i want is some name here - text here longer name here - text here even longer name here - text here short name - text here well the "- text here" should be in a line but i cant get it right here either can anyone help me fix it ive see how to do it somewhere but cant find it now

        S Offline
        S Offline
        sudhir_Kumar
        wrote on last edited by
        #3

        use temp.Format("%-50s %10s %s\r\n", m_list.GetItemText(index, 0), "-", m_list.GetItemText(index, 2)); May be thi can help you.

        -@SuDhIrKuMaR@-

        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