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. can't add elements in the column

can't add elements in the column

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

    Hi i've strange problem.i've 4 columns Account,date,amount,address in a Clist Control. //a breif abt my project in my project am trying to slect a file by browsing (i used cfiledialog). & then pressing the button 'showbutton' i want to see all the documents(i.e.account,date,amount,address) of that file.this file is actually a list of several transaction......... now in this project i didn't use classwizard, all the message mapping,dialog creation i've done mannually............... //the problem now, the problem is, while am trynig to insert items in the r8 column, only the 1st column is being populated , not the others....in the insertion column CString strItem; LVITEM lvi; lvi.mask = LVIF_TEXT; //Account no... strItem.Format(_T(&TP->TR.Account[1])); lvi.iSubItem = 0; lvi.pszText = (LPTSTR)(LPCTSTR)(strItem); m_cListCtrl.InsertItem( &lvi); //Expirary Date strItem.Format(_T(&TP->TR.ExpDate[1])); lvi.iSubItem = 1; lvi.pszText = (LPTSTR)(LPCTSTR)( strItem); m_cListCtrl.InsertItem( &lvi); nd this way only putting "lvi.iSubItem=2,3...4" Don't get confused with TP,TR...these r my project variables for other issues. using that above code.. am getting only 1st column.... waiting for quick reply.....A GOOD DAY to all. kamalesh

    D L 3 Replies Last reply
    0
    • K kamalesh82

      Hi i've strange problem.i've 4 columns Account,date,amount,address in a Clist Control. //a breif abt my project in my project am trying to slect a file by browsing (i used cfiledialog). & then pressing the button 'showbutton' i want to see all the documents(i.e.account,date,amount,address) of that file.this file is actually a list of several transaction......... now in this project i didn't use classwizard, all the message mapping,dialog creation i've done mannually............... //the problem now, the problem is, while am trynig to insert items in the r8 column, only the 1st column is being populated , not the others....in the insertion column CString strItem; LVITEM lvi; lvi.mask = LVIF_TEXT; //Account no... strItem.Format(_T(&TP->TR.Account[1])); lvi.iSubItem = 0; lvi.pszText = (LPTSTR)(LPCTSTR)(strItem); m_cListCtrl.InsertItem( &lvi); //Expirary Date strItem.Format(_T(&TP->TR.ExpDate[1])); lvi.iSubItem = 1; lvi.pszText = (LPTSTR)(LPCTSTR)( strItem); m_cListCtrl.InsertItem( &lvi); nd this way only putting "lvi.iSubItem=2,3...4" Don't get confused with TP,TR...these r my project variables for other issues. using that above code.. am getting only 1st column.... waiting for quick reply.....A GOOD DAY to all. kamalesh

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

      kamalesh82 wrote:

      strItem.Format(_T(&TP->TR.Account[1]));

      The _T() macro is only needed with string literals. Also, why use the Format() method when you can assign &TP->TR.Account[1] directly to strItem? Try:

      int nItem = m_cListCtrl.InsertItem(0, &TP->TR.Account[1]);
      m_cListCtrl.SetItemText(nItem, 1, &TP->TR.ExpDate[1]);


      "The largest fire starts but with the smallest spark." - David Crow

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

      K 1 Reply Last reply
      0
      • D David Crow

        kamalesh82 wrote:

        strItem.Format(_T(&TP->TR.Account[1]));

        The _T() macro is only needed with string literals. Also, why use the Format() method when you can assign &TP->TR.Account[1] directly to strItem? Try:

        int nItem = m_cListCtrl.InsertItem(0, &TP->TR.Account[1]);
        m_cListCtrl.SetItemText(nItem, 1, &TP->TR.ExpDate[1]);


        "The largest fire starts but with the smallest spark." - David Crow

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

        K Offline
        K Offline
        kamalesh82
        wrote on last edited by
        #3

        &TP->TR.Account[1] returns the string literal.so be sure that it's not making any problem. nd i used SetItemText as well as the SetItem both function. Good Day kamalesh

        1 Reply Last reply
        0
        • K kamalesh82

          Hi i've strange problem.i've 4 columns Account,date,amount,address in a Clist Control. //a breif abt my project in my project am trying to slect a file by browsing (i used cfiledialog). & then pressing the button 'showbutton' i want to see all the documents(i.e.account,date,amount,address) of that file.this file is actually a list of several transaction......... now in this project i didn't use classwizard, all the message mapping,dialog creation i've done mannually............... //the problem now, the problem is, while am trynig to insert items in the r8 column, only the 1st column is being populated , not the others....in the insertion column CString strItem; LVITEM lvi; lvi.mask = LVIF_TEXT; //Account no... strItem.Format(_T(&TP->TR.Account[1])); lvi.iSubItem = 0; lvi.pszText = (LPTSTR)(LPCTSTR)(strItem); m_cListCtrl.InsertItem( &lvi); //Expirary Date strItem.Format(_T(&TP->TR.ExpDate[1])); lvi.iSubItem = 1; lvi.pszText = (LPTSTR)(LPCTSTR)( strItem); m_cListCtrl.InsertItem( &lvi); nd this way only putting "lvi.iSubItem=2,3...4" Don't get confused with TP,TR...these r my project variables for other issues. using that above code.. am getting only 1st column.... waiting for quick reply.....A GOOD DAY to all. kamalesh

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Hi, here is my example without lvItem structure: // this works! i -> my linenumber and 1 is the first subitem! ctrlList->SetItem(i, 1, LVIF_TEXT, MyTextHere, 0,NULL, NULL, 0); // i dont try this, but you can do this! //you can change to lvItem.iSubItem = 1; ctrlList.Setitem(&lvItem); i hope that helps! regards break; -- modified at 10:07 Thursday 6th July, 2006

          1 Reply Last reply
          0
          • K kamalesh82

            Hi i've strange problem.i've 4 columns Account,date,amount,address in a Clist Control. //a breif abt my project in my project am trying to slect a file by browsing (i used cfiledialog). & then pressing the button 'showbutton' i want to see all the documents(i.e.account,date,amount,address) of that file.this file is actually a list of several transaction......... now in this project i didn't use classwizard, all the message mapping,dialog creation i've done mannually............... //the problem now, the problem is, while am trynig to insert items in the r8 column, only the 1st column is being populated , not the others....in the insertion column CString strItem; LVITEM lvi; lvi.mask = LVIF_TEXT; //Account no... strItem.Format(_T(&TP->TR.Account[1])); lvi.iSubItem = 0; lvi.pszText = (LPTSTR)(LPCTSTR)(strItem); m_cListCtrl.InsertItem( &lvi); //Expirary Date strItem.Format(_T(&TP->TR.ExpDate[1])); lvi.iSubItem = 1; lvi.pszText = (LPTSTR)(LPCTSTR)( strItem); m_cListCtrl.InsertItem( &lvi); nd this way only putting "lvi.iSubItem=2,3...4" Don't get confused with TP,TR...these r my project variables for other issues. using that above code.. am getting only 1st column.... waiting for quick reply.....A GOOD DAY to all. kamalesh

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            you should set the itemidentifier for the subitem, subitem must to know to witch item is to add!? i solve your problem like this: // one lvItem only for SubItems LVITEM lvItem; lvItem.iItem = 0; // this is important!!! can be any linenumber from your listctrl! lvItem.iSubItem = 1; // first subitem lvItem.mask = LVIF_TEXT; // example for iterating: int i = 0; while(i < 10) { // listctrl have only two columns! // Set Subitems Text to 10 Items! lvItem.iItem = i; // first item(first line in the listctrl) //lvItem.iSubItem = 1; // first subitem, stay the same, we dont need to change them here! lvItem.pszText = (LPTSTR)(LPCTSTR) NewText; listCtrl->SetItem(&lvItem); i++; } i try this and it works! regards break; -- modified at 10:43 Thursday 6th July, 2006

            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