如何在两个列表控件之间有效地复制内容

时间:2018-01-24 17:53:27

标签: c++ mfc listcontrol

我想将行从一个List Control复制到另一个List Control。我只能按子项复制它们。我觉得这不是很有效率。必须有一种方法来按行复制内容。以下是我的代码,一次复制一个子项目的内容。

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++;
    }
}

是否有人可以通过直接从m_listm_report_list复制行来提供替换for循环的方法?我认为这样的方式必须节省很多时间。

0 个答案:

没有答案