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. saving list control data in a string

saving list control data in a string

Scheduled Pinned Locked Moved C / C++ / MFC
5 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.
  • B Offline
    B Offline
    brucewayn
    wrote on last edited by
    #1

    I'm working on a list control application. When i double click on a row, i want to save the data in the 3rd column of that selected row to be store in a string. Please tel me know how can this be achieved. Thanks in Advance

    _ S 2 Replies Last reply
    0
    • B brucewayn

      I'm working on a list control application. When i double click on a row, i want to save the data in the 3rd column of that selected row to be store in a string. Please tel me know how can this be achieved. Thanks in Advance

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      You can do that using the CListCtrl class The following member functions need to be used - GetFirstSelectedItemPosition GetNextSelectedItem GetItemText

      «_Superman_»

      1 Reply Last reply
      0
      • B brucewayn

        I'm working on a list control application. When i double click on a row, i want to save the data in the 3rd column of that selected row to be store in a string. Please tel me know how can this be achieved. Thanks in Advance

        S Offline
        S Offline
        Sarath C
        wrote on last edited by
        #3

        // Map double click using event handling ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CListSampleDlg::OnNMDblclkList) // in the callback function

        void CListSampleDlg::OnNMDblclkList(NMHDR *pNMHDR, LRESULT *pResult)
        {
        LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR);

        // Get 3rd item's text.
        CString str = m\_List.GetItemText( pNMItemActivate->iItem, 2 );
        
        AfxMessageBox( str );
        
        \*pResult = 0;
        

        }

        is this what you want?

        -Sarath. "Great hopes make everything great possible" - Benjamin Franklin

        My blog - Sharing My Thoughts

        B 1 Reply Last reply
        0
        • S Sarath C

          // Map double click using event handling ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CListSampleDlg::OnNMDblclkList) // in the callback function

          void CListSampleDlg::OnNMDblclkList(NMHDR *pNMHDR, LRESULT *pResult)
          {
          LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR);

          // Get 3rd item's text.
          CString str = m\_List.GetItemText( pNMItemActivate->iItem, 2 );
          
          AfxMessageBox( str );
          
          \*pResult = 0;
          

          }

          is this what you want?

          -Sarath. "Great hopes make everything great possible" - Benjamin Franklin

          My blog - Sharing My Thoughts

          B Offline
          B Offline
          brucewayn
          wrote on last edited by
          #4

          Thank you for the code. Though it wasn't working I got an idea and completed the required one. But if i want to save the data of the 3rd column in a string of about more than one selected rows with "|" as separator. Please let me know how can this achieved. Thanks in advance

          S 1 Reply Last reply
          0
          • B brucewayn

            Thank you for the code. Though it wasn't working I got an idea and completed the required one. But if i want to save the data of the 3rd column in a string of about more than one selected rows with "|" as separator. Please let me know how can this achieved. Thanks in advance

            S Offline
            S Offline
            Sarath C
            wrote on last edited by
            #5

            I believe Superman already given you idea on getting text of selected items. Here's the code snippet. Please check MSDN.It contains lot of sample snippet with documentation

            CString strColumText;
            POSITION pos = m_List.GetFirstSelectedItemPosition();
            if (pos == NULL)
            {
            TRACE(_T("No items were selected!\n"));
            }
            else
            {
            while (pos)
            {
            int nItem = m_List.GetNextSelectedItem(pos);
            strColumText += _T("|") + m_List.GetItemText( nItem, 2 );
            }
            }

            -Sarath. "Great hopes make everything great possible" - Benjamin Franklin

            My blog - Sharing My Thoughts

            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