How to efficiently copy contents between two list controls

67 views Asked by At

I want to copy rows from one List Control to another List Control. I am only able to copy them by sub item. I think this is not very efficient. There must be a method to copy the content by rows. The following is my code that copies content one sub item at a time.

CString CurItem, tem, copystr;
int j = 0;
m_combo_list.GetLBText(m_combo_list.GetCurSel(), CurItem);
for (int i = 0; i < m_list.GetItemCount(); i++) {
    tem = m_list.GetItemText(i, 0);
    if (CurItem == tem) {
        m_report_list.InsertItem(j, _T(""));
        for (int k = 0; k < 14; k++) { // 14 items per row.
            copystr = m_list.GetItemText(i, k);// get one item per time from one list control.
            m_report_list.SetItemText(j, k, copystr); // this is another list control. Copy the item to this list control.

        }
        j++;
    }
}

Could anyone give a method to replace the for loop by copy a row from m_list to m_report_list directly? I think such a way must save a lot of time.

0

There are 0 answers