Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am new to VC++ programming, could anyone help me with TreeControl.

There are around 40000 elements(stored in an array) to be loaded to a Treecontrol and it takes around 2 minutes, does anyone suggest me a better and faster way?

The snippet of code is something like this:

C#
int CDerivedfromTreeView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
    unsigned int    i,k;
    CTreeCtrl &controlList = (CTreeCtrl &) GetTreeCtrl(); 
    if (CTreeView::OnCreate(lpCreateStruct) == -1)
        return -1;
    controlList.ModifyStyle(0L, TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_NOTOOLTIPS | TVS_SHOWSELALWAYS ); 
    controlList.SetRedraw(TRUE);
    if(controlList.GetCount() )
    controlList.DeleteAllItems();
    controlList.SetRedraw(FALSE);

    for(i=0;i<global_Total_No_Of_Items;i++)
    {
        controlList.InsertItem( (LPCTSTR)items[i].name ,TVI_ROOT,TVI_LAST);
        
    }
        controlList.SetRedraw(TRUE);
    SplitterWindow = CView::GetParentSplitter(this, TRUE);
    return 0;
}



Thanks in advance,
RafiM
Posted
Updated 7-Feb-10 10:50am
v2

1 solution

So you set up a tree control, with 40,000 elements, all at the root, and you're worried that it takes 2 minutes to populate ? This is INSANE UI, I assume you expect your user to now add elements below the root, for the tree control to do anything, and they have 40,000 elements to search through ?

I think your UI needs a rethink. .003 of a second is a reasonable amount of time for it to take to insert an item into a treeview.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900