Again CListCtrl
-
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
-
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
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
-
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
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_
-
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
And how would your code know which item is checked :doh:
Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
-
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
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
-
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_
ok but : error C2065: 'nColumn' : undeclared identifier its not right !something is wrong ! what ?
Bravoone
-
ok but : error C2065: 'nColumn' : undeclared identifier its not right !something is wrong ! what ?
Bravoone
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] -
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_
THANKS GUYS ! EVERYTING IS OK ! THANKS !
Bravoone
-
THANKS GUYS ! EVERYTING IS OK ! THANKS !
Bravoone
:-D
Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_