Link to home
Start Free TrialLog in
Avatar of hon67
hon67

asked on

Virtual ListView!!!

Hi,

As I am using VC++5.0 to develop my application, I need to display a lot of data (probably > 50000 items). Thus I choose to use Virtual Listview!!!

Now I face the following two problems!!!

1.) How get I get the text from the virtual listview?
     I found GetItemText() cannot return the text from the listview.

2.) How can I do the sorting the each column?

Thanks!!!
Avatar of Vinayak Kumbar
Vinayak Kumbar

Hi,

>1.) How get I get the text from the virtual listview?
                          I found GetItemText() cannot return the text from the listview.

Just try one thing, After U calling the InsertItem(...) call SetItemText(...), I think this problem will be solved. If some paiting problems come, then just use Invalidate().

For sorting u have to write a compare function and sort. U will get lot of samples in the codeguru.developer.com listview section.

Try it out.

All the best
VinExpert
ASKER CERTIFIED SOLUTION
Avatar of ch_vasu
ch_vasu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hon67

ASKER

Hello ch_vasu,

Previously, I am not using Virtual Listview to display the data, I insert data and do the sorting of the listview like this:

--------------------------------------------------------
struct info
 {
     CString col1;
     CString clo2;
    CString col3;
};

 LV_ITEM lvi;
 lvi.mask = LVIF_TEXT | LVIF_PARAM;

 for(i = 0; i < nItems; i++)   // nItems = no of rows
{
      lvi.iItem = i;
      lvi.pszText = "Some thing";  //col 0 text
      struct info* pInfo = new struct info;
      pInfo->col0 = "Col1";
      pInfo->col1 = "Col2";
      pInfo->col2 = "Col3";

      lvi.lParam = (DWORD)pInfo;
      m_list1.InsertItem(lvi);
      m_lst1.SetItemText(nItems,1,"Col2");
      m_lst1.SetItemText(nItems,2,"Col3");
     
}

// sort the listview like this

pmyListCtrl->SortItems(MyCompareProc, (LPARAM) nColumnClicked);
------------------------------------------------------

Then I also do the sorting by using the callback function, but I do the comparsion by using the
structure pInfo instead of using the GetItemText function.

Now If I am using Virtual Listview, I found I don't need to use the InsertItem function and fill in the
LV_ITEM Structure.

I want to know whether I still can use this method to do the sorting.

Further, according to your suggested method?
What is the time need to sorting for about 50000 rows with 10 cols? I afraid the time use to call the function GetItemText is very time consuming?                  


You will get more information about how to RetrieveItem from Virtual list control in MSDN help.
1. To get the Help type 'List View Updates in Internet Explorer' in the MSDN index. There click on heperlink 'Virtual List View'. You can change use that sample code to continue.  

Note :- The section "Compatibility issues: styles, states, and messages" in MSDN says --

List View Control Styles: All four of the list view styles (icon, small icon, list, and report view) support the LVS_OWNERDATA style. However, this style will not work with the LVS_SORTASCENDING or LVS_SORTDESCENDING style.

I believe by using Cache Management you can reduce the sort time.

Try this
All the Best.
-Vasudev