CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Adding a lot of data to list control

  1. #1
    Join Date
    Sep 2006
    Posts
    28

    Adding a lot of data to list control

    My project have a list control and have to add a lot of data to it(more than 1000 item) I use these code for add each item.
    <pre>
    void AddDataList(CListCtrl *m_list, int row,
    CString col0, CString col1, CString col2,
    CString col3, CString col4, CString col5)
    {

    LVITEM lvi;
    lvi.mask = LVIF_TEXT;lvi.iItem=row;
    lvi.iSubItem = 0;lvi.pszText = (char*)(LPCTSTR)col0;
    m_list->InsertItem(&lvi);

    lvi.iSubItem = 1;lvi.pszText = (char*)(LPCTSTR)col1;
    m_list->SetItem(&lvi);

    lvi.iSubItem = 2;lvi.pszText = (char*)(LPCTSTR)col2;
    m_list->SetItem(&lvi);

    lvi.iSubItem = 3;lvi.pszText = (char*)(LPCTSTR)col3;
    m_list->SetItem(&lvi);

    lvi.iSubItem = 4;lvi.pszText = (char*)(LPCTSTR)col4;
    m_list->SetItem(&lvi);

    lvi.iSubItem = 5;lvi.pszText = (char*)(LPCTSTR)col5;
    m_list->SetItem(&lvi);

    }
    </pre>
    my problem is that
    while program is adding the item my program look like hang up,
    because the list control is updated every time when it add item.

    How can I do if I want to update it only one time when it finish adding item.

  2. #2
    Join Date
    Aug 2007
    Location
    Farnborough, Hants, UK
    Posts
    45

    Re: Adding a lot of data to list control

    Take a look at the SetRedraw() method. This can be used to prevent visual updates until you have finished adding, and then you can set the flag back again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)