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. [Message Deleted]

[Message Deleted]

Scheduled Pinned Locked Moved C / C++ / MFC
3 Posts 2 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.
  • J Offline
    J Offline
    Jan Hirak
    wrote on last edited by
    #1

    [Message Deleted]

    D 2 Replies Last reply
    0
    • J Jan Hirak

      [Message Deleted]

      D Offline
      D Offline
      dazinith
      wrote on last edited by
      #2

      the list control must know the string to put in the list control, if you need to put an integer or a double, etc. then you should format it first. i show alot of integers in some of my lists, so i wrote a simple int to string function.. something like:

      CString CCommonFunctions::toString(int nVal)
      {
      CString strTemp;
      strTemp.Format("%i", nVal);
      return strTemp;
      }

      that way when you add your value to the list control you can just use

      m_lstMyList.InsertItem(0, CCommonFunctions::toString(nMyInt));

      also remember you can set a pointer to each object incase you need to associate each item with a custom object

      CMyObject* myObj = new CMyObject("blah",1,20);
      m_lstMyList.InsertItem(nPos, CCommonFunctions::toString(myObj->m_nX));
      m_lstMyList.SetItemData(nPos, (DWORD) myObj);

      then later use GetItemData()

      CMyObject* myObj = NULL;
      int nPos = m_lstMyList.GetSelectionMark();
      if (nPos != -1)
      {
      myObj = m_lstMyList.GetItemData(nPos);
      }

      -dz

      1 Reply Last reply
      0
      • J Jan Hirak

        [Message Deleted]

        D Offline
        D Offline
        dazinith
        wrote on last edited by
        #3

        didnt see you were asking about doubles specifically.. something like this:

        CString strDouble;
        strDouble.Format("%f", dDouble);
        m_lstMyList.InsertItem(0, strDouble.Left(4)); // use the left command to get only the number of digits you want

        -dz

        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