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. CListCtrl

CListCtrl

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

    Hi I was wondering if some one could help me with the sort function of CList control. My first column consists of numbers to be added by the user. I need the numbers to be sorted but If I make the member variable integers I am unable to use the InsertItem function so am I restricted to CStrings?:confused:

    N 1 Reply Last reply
    0
    • C Catherine

      Hi I was wondering if some one could help me with the sort function of CList control. My first column consists of numbers to be added by the user. I need the numbers to be sorted but If I make the member variable integers I am unable to use the InsertItem function so am I restricted to CStrings?:confused:

      N Offline
      N Offline
      NapiSpooler
      wrote on last edited by
      #2

      Catherine... were you referring to sorting a CList or CListCtrl?

      C 1 Reply Last reply
      0
      • N NapiSpooler

        Catherine... were you referring to sorting a CList or CListCtrl?

        C Offline
        C Offline
        Catherine
        wrote on last edited by
        #3

        I have an Edit control where the user enters a number. When the user presses return the number gets added to a CListCtrl. The edit control's member variable is a CString. I want the numbers in the ListCtrl to be sorted numerically, however by selecting ascending sort on the ListCtrl the nubers appear for example in this order: 1 2 22 3 4

        N 1 Reply Last reply
        0
        • C Catherine

          I have an Edit control where the user enters a number. When the user presses return the number gets added to a CListCtrl. The edit control's member variable is a CString. I want the numbers in the ListCtrl to be sorted numerically, however by selecting ascending sort on the ListCtrl the nubers appear for example in this order: 1 2 22 3 4

          N Offline
          N Offline
          NapiSpooler
          wrote on last edited by
          #4

          it sounds like you might need to convert your CStrings to ints (using the atoi()) during your sort function, something similar to: int n1 = atoi((const char*) pListCtrl->GetItemText(lParam1, 0)); int n2 = atoi((const char*) pListCtrl->GetItemText(lParam2, 0)); then doing the comparision on the ints.

          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