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. How move a CListCtrl item?!

How move a CListCtrl item?!

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
2 Posts 2 Posters 1 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.
  • X Offline
    X Offline
    XAlien
    wrote on last edited by
    #1

    Hi all, I have a CListCtrl that contains some only-text item, I want to move(pressing a button) the selected item up/down in the list but how? I have to use "SetItemPosition"? There wasn't a method to move the item of only one position? Help me please, and sorry for my english! Thanks.:-O

    T 1 Reply Last reply
    0
    • X XAlien

      Hi all, I have a CListCtrl that contains some only-text item, I want to move(pressing a button) the selected item up/down in the list but how? I have to use "SetItemPosition"? There wasn't a method to move the item of only one position? Help me please, and sorry for my english! Thanks.:-O

      T Offline
      T Offline
      Thomas Blenkers
      wrote on last edited by
      #2

      When you are in Report mode, something like this SwapRows function should help: void CMyListCtrl::SwapRows(int row1, int row2) { // rowText will hold all column text for one row CStringArray rowText; LV_ITEM lvitemrow1, lvitemrow2; int nColCount = GetColumnCount(); rowText.SetSize( nColCount ); int i; for( i=0; i < nColCount; i++) rowText[i] = GetItemText(row1, i); lvitemrow1.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_STATE; lvitemrow1.iItem = row1; lvitemrow1.iSubItem = 0; lvitemrow1.stateMask = LVIS_CUT | LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED | LVIS_OVERLAYMASK | LVIS_STATEIMAGEMASK; lvitemrow2 = lvitemrow1; lvitemrow2.iItem = row2; GetItem( &lvitemrow1 ); GetItem( &lvitemrow2 ); for( i=0; i< nColCount; i++) SetItemText(row1, i, GetItemText(row2, i) ); lvitemrow2.iItem = row1; SetItem( &lvitemrow2 ); for( i=0; i< nColCount; i++) SetItemText(row2, i, rowText[i]); lvitemrow1.iItem = row2; SetItem( &lvitemrow1 ); } WM_HOPEITHELPED

      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