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

Again CListCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
question
9 Posts 4 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.
  • B Offline
    B Offline
    Bravoone_2006
    wrote on last edited by
    #1

    How can i Sum Rows in column 3 i have selected ? ok,this code sum all rows in all columns : int nSum = 0; for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++) { for( int nColumn = 0; nColumn < 3;nColumn++) { csText = m_list1.GetItemText(nRow ,nColumn ); nSum += atoi( csText); } } csText.Format("%d", nSum); m_sum.SetWindowText(csText); I have added Checkboxes to CListCtrl to select witch rows to Sum,ALL I WANT IS TO SUM ROWS IN COLUMN 3 THAT I HAVE SELECTED !!! HOW ?

    Bravoone

    N _ 2 Replies Last reply
    0
    • B Bravoone_2006

      How can i Sum Rows in column 3 i have selected ? ok,this code sum all rows in all columns : int nSum = 0; for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++) { for( int nColumn = 0; nColumn < 3;nColumn++) { csText = m_list1.GetItemText(nRow ,nColumn ); nSum += atoi( csText); } } csText.Format("%d", nSum); m_sum.SetWindowText(csText); I have added Checkboxes to CListCtrl to select witch rows to Sum,ALL I WANT IS TO SUM ROWS IN COLUMN 3 THAT I HAVE SELECTED !!! HOW ?

      Bravoone

      N Offline
      N Offline
      Nibu babu thomas
      wrote on last edited by
      #2

      Bravoone_2006 wrote:

      int nSum = 0; for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++) { for( int nColumn = 0; nColumn < 3;nColumn++) { csText = m_list1.GetItemText(nRow ,nColumn ); nSum += atoi( csText); } }

      int nSum = 0;
      for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++)
      {
      csText = m_list1.GetItemText( nRow, 2 );
      nSum += atoi( csText);
      }


      Nibu thomas A Developer Code must be written to be read, not by the compiler, but by another human being. http:\\nibuthomas.wordpress.com

      _ B 2 Replies Last reply
      0
      • B Bravoone_2006

        How can i Sum Rows in column 3 i have selected ? ok,this code sum all rows in all columns : int nSum = 0; for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++) { for( int nColumn = 0; nColumn < 3;nColumn++) { csText = m_list1.GetItemText(nRow ,nColumn ); nSum += atoi( csText); } } csText.Format("%d", nSum); m_sum.SetWindowText(csText); I have added Checkboxes to CListCtrl to select witch rows to Sum,ALL I WANT IS TO SUM ROWS IN COLUMN 3 THAT I HAVE SELECTED !!! HOW ?

        Bravoone

        _ Offline
        _ Offline
        _AnsHUMAN_
        wrote on last edited by
        #3

        Hi Bravoone, Try pasting this code in the first for loop int nSum = 0; for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++) { for( int nColumn = 0; nColumn < 3;nColumn++) { if(m_list1.GetCheck(/*index of item*/nRow)) { csText = m_list1.GetItemText(nRow ,nColumn ); nSum += atoi( csText); } } // Rest of the code.

        Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

        B 2 Replies Last reply
        0
        • N Nibu babu thomas

          Bravoone_2006 wrote:

          int nSum = 0; for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++) { for( int nColumn = 0; nColumn < 3;nColumn++) { csText = m_list1.GetItemText(nRow ,nColumn ); nSum += atoi( csText); } }

          int nSum = 0;
          for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++)
          {
          csText = m_list1.GetItemText( nRow, 2 );
          nSum += atoi( csText);
          }


          Nibu thomas A Developer Code must be written to be read, not by the compiler, but by another human being. http:\\nibuthomas.wordpress.com

          _ Offline
          _ Offline
          _AnsHUMAN_
          wrote on last edited by
          #4

          And how would your code know which item is checked :doh:

          Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

          1 Reply Last reply
          0
          • N Nibu babu thomas

            Bravoone_2006 wrote:

            int nSum = 0; for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++) { for( int nColumn = 0; nColumn < 3;nColumn++) { csText = m_list1.GetItemText(nRow ,nColumn ); nSum += atoi( csText); } }

            int nSum = 0;
            for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++)
            {
            csText = m_list1.GetItemText( nRow, 2 );
            nSum += atoi( csText);
            }


            Nibu thomas A Developer Code must be written to be read, not by the compiler, but by another human being. http:\\nibuthomas.wordpress.com

            B Offline
            B Offline
            Bravoone_2006
            wrote on last edited by
            #5

            OK, but it works for col 2 but I WANT to select witch rows to sum HOW? i have try this but it sum all rows in column 2! : CString csText; for(int i=0; iBravoone

            1 Reply Last reply
            0
            • _ _AnsHUMAN_

              Hi Bravoone, Try pasting this code in the first for loop int nSum = 0; for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++) { for( int nColumn = 0; nColumn < 3;nColumn++) { if(m_list1.GetCheck(/*index of item*/nRow)) { csText = m_list1.GetItemText(nRow ,nColumn ); nSum += atoi( csText); } } // Rest of the code.

              Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

              B Offline
              B Offline
              Bravoone_2006
              wrote on last edited by
              #6

              ok but : error C2065: 'nColumn' : undeclared identifier its not right !something is wrong ! what ?

              Bravoone

              C 1 Reply Last reply
              0
              • B Bravoone_2006

                ok but : error C2065: 'nColumn' : undeclared identifier its not right !something is wrong ! what ?

                Bravoone

                C Offline
                C Offline
                Cedric Moonen
                wrote on last edited by
                #7

                Bravoone_2006 wrote:

                error C2065: 'nColumn' : undeclared identifier its not right !something is wrong ! what ?

                :wtf: Are you kidding ? I think the erro message is pretty clear no ? You are using nColumn in your code and it has not been declared anywhere. BTW, when somebody gives you code snippet, it is always better to try to understand what it does so that next time you can do it yourself, instead of blindly copy/pasting into your own code. If you tried to do that, maybe with all the answer you got you would probably have had a working solution. Don't expect people to do everything for you.


                Cédric Moonen Software developer
                Charting control [v1.2]

                1 Reply Last reply
                0
                • _ _AnsHUMAN_

                  Hi Bravoone, Try pasting this code in the first for loop int nSum = 0; for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++) { for( int nColumn = 0; nColumn < 3;nColumn++) { if(m_list1.GetCheck(/*index of item*/nRow)) { csText = m_list1.GetItemText(nRow ,nColumn ); nSum += atoi( csText); } } // Rest of the code.

                  Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

                  B Offline
                  B Offline
                  Bravoone_2006
                  wrote on last edited by
                  #8

                  THANKS GUYS ! EVERYTING IS OK ! THANKS !

                  Bravoone

                  _ 1 Reply Last reply
                  0
                  • B Bravoone_2006

                    THANKS GUYS ! EVERYTING IS OK ! THANKS !

                    Bravoone

                    _ Offline
                    _ Offline
                    _AnsHUMAN_
                    wrote on last edited by
                    #9

                    :-D

                    Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

                    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