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. MFC vc++ deleting column in list view control

MFC vc++ deleting column in list view control

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

    In the blow code snippet, the DeleteColumn parameters takes 0 instead of "i" from the for loop. Why do we use 0 there and when I try using "i" there it didn't completely delete the column. I can't understand the process.

    int nColumnCount = m_myListCtrl.GetHeaderCtrl()->GetItemCount();

        // Delete all of the columns.
        for (int i=0; i < nColumnCount; i++)
        {
            m\_myListCtrl.DeleteColumn(0);// here why do we use 0 instead of "i" and when I use 
                                                  //"i" it didn't completely delete the column.
        }
    
    V 1 Reply Last reply
    0
    • M Member_14575556

      In the blow code snippet, the DeleteColumn parameters takes 0 instead of "i" from the for loop. Why do we use 0 there and when I try using "i" there it didn't completely delete the column. I can't understand the process.

      int nColumnCount = m_myListCtrl.GetHeaderCtrl()->GetItemCount();

          // Delete all of the columns.
          for (int i=0; i < nColumnCount; i++)
          {
              m\_myListCtrl.DeleteColumn(0);// here why do we use 0 instead of "i" and when I use 
                                                    //"i" it didn't completely delete the column.
          }
      
      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      After you have deleted the column 0 the next column (the former column 1) becomes the column 0. Another way to delete all the columns:

        for (int i = nColumnCount - 1; i >= 0; i--)
        {
            m\_myListCtrl.DeleteColumn(i);
        }
      
      M 1 Reply Last reply
      0
      • V Victor Nijegorodov

        After you have deleted the column 0 the next column (the former column 1) becomes the column 0. Another way to delete all the columns:

          for (int i = nColumnCount - 1; i >= 0; i--)
          {
              m\_myListCtrl.DeleteColumn(i);
          }
        
        M Offline
        M Offline
        Member_14575556
        wrote on last edited by
        #3

        Okay now I understand. Thanks :)

        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