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. A simple question about CListCtrl::InsertItem

A simple question about CListCtrl::InsertItem

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

    This is a simple question, I'm sure you have the answer, help me out please. I have a List control in my dialog, to which I associate a member variable of CListCtrl. The style of this control is: General: Visible, Tab stop Styles: View-Report, Align-Left, Sort-None, Single Selection, Edit Labels, No column header, Show selection always More Styles: Border Extended Styles: Static edge. In the OnInitDialog, I had the following: m_myListCtrl.InsertItem(0, "item 0"); But when the dialog is displayed, nothing in the list control!:mad::mad: What am I missing?

    L 1 Reply Last reply
    0
    • L lucy 0

      This is a simple question, I'm sure you have the answer, help me out please. I have a List control in my dialog, to which I associate a member variable of CListCtrl. The style of this control is: General: Visible, Tab stop Styles: View-Report, Align-Left, Sort-None, Single Selection, Edit Labels, No column header, Show selection always More Styles: Border Extended Styles: Static edge. In the OnInitDialog, I had the following: m_myListCtrl.InsertItem(0, "item 0"); But when the dialog is displayed, nothing in the list control!:mad::mad: What am I missing?

      L Offline
      L Offline
      lucy 0
      wrote on last edited by
      #2

      sigh, it turned out that I have to do more overhead work: m_myListCtrl.InsertColumn(0, "First Column", LVCFMT_LEFT, nWidth); m_myListCtrl.InsertItem(0, "my item"); beats me! X|

      X 1 Reply Last reply
      0
      • L lucy 0

        sigh, it turned out that I have to do more overhead work: m_myListCtrl.InsertColumn(0, "First Column", LVCFMT_LEFT, nWidth); m_myListCtrl.InsertItem(0, "my item"); beats me! X|

        X Offline
        X Offline
        xxhimanshu
        wrote on last edited by
        #3

        :)hi, this is what we do.. as m_List.InsertColumn( // Ask Mfc to create/insert a column 0, // This is the rank/order of this // particular item "Name", // The caption we want for this header LVCFMT_LEFT, // The relative position we want the // items under this header to have 100); // The width we want for the items under // this header m_List.InsertColumn(1, "Profession", LVCFMT_CENTER, 80); m_List.InsertColumn(2, "Fav. Sport", LVCFMT_LEFT, 100); m_List.InsertColumn(3, "Hobby", LVCFMT_LEFT, 80); and to add items.. provide some items to display under the headers: int nItem; // This integer will be used to identify the // header item we are dealing with. // Give a name/caption to an item to display under the first header nItem = m_List.InsertItem(0, "Sandra"); // Create a caption for the corresponding headers. m_List.SetItemText(nItem, 1, "Singer"); m_List.SetItemText(nItem, 2, "HandBall"); m_List.SetItemText(nItem, 3, "Beach"); i hope so you get..why you were getting an error.. cheers Himanshu

        L 1 Reply Last reply
        0
        • X xxhimanshu

          :)hi, this is what we do.. as m_List.InsertColumn( // Ask Mfc to create/insert a column 0, // This is the rank/order of this // particular item "Name", // The caption we want for this header LVCFMT_LEFT, // The relative position we want the // items under this header to have 100); // The width we want for the items under // this header m_List.InsertColumn(1, "Profession", LVCFMT_CENTER, 80); m_List.InsertColumn(2, "Fav. Sport", LVCFMT_LEFT, 100); m_List.InsertColumn(3, "Hobby", LVCFMT_LEFT, 80); and to add items.. provide some items to display under the headers: int nItem; // This integer will be used to identify the // header item we are dealing with. // Give a name/caption to an item to display under the first header nItem = m_List.InsertItem(0, "Sandra"); // Create a caption for the corresponding headers. m_List.SetItemText(nItem, 1, "Singer"); m_List.SetItemText(nItem, 2, "HandBall"); m_List.SetItemText(nItem, 3, "Beach"); i hope so you get..why you were getting an error.. cheers Himanshu

          L Offline
          L Offline
          lucy 0
          wrote on last edited by
          #4

          Thank you, Himanshu. I got it now. This list control is more complext to use than those combo box and edit control. :(

          J 1 Reply Last reply
          0
          • L lucy 0

            Thank you, Himanshu. I got it now. This list control is more complext to use than those combo box and edit control. :(

            J Offline
            J Offline
            Jean Marc Molina
            wrote on last edited by
            #5

            Yes first you have to insert columns, then you can insert rows as items. Finally you can set each columns values for that new item : InsertColumn, InsertItem, SetItem for each column... Hope it helps, JM Earth > Europe > France > Lyon

            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