Performance problem when deleting items from grid |
Post Reply |
Author | ||
farr02
Groupie Joined: 10 May 2005 Status: Offline Points: 51 |
Post Options
Thanks(0)
Posted: 03 January 2008 at 4:00am |
|
Hello,
in my application I noticed a performance problem when deleting a large number of elements from the grid via pItem->Remove(); Example: First I create a large number of categories each holds two items:
Then I delete 'Element 1' in every category using the following code:
The removal of the elements takes more than a minute in release configuration on a 3 GHz computer running Win XP and ToolkitPro v9.81, whereas creation time is less than a second. Is something wrong with my code or takes the remove-function so much time? (I think the problem may be the call to m_pGrid->Refresh(); in the remove function.) How can I speed up the removal? Bye Holger |
||
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
|
Hi,
There are BeginUpdate, EndUpdate methods.
call them before/after your loop.
|
||
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
||
farr02
Groupie Joined: 10 May 2005 Status: Offline Points: 51 |
Post Options
Thanks(0)
|
|
Hello Oleg,
I have already made some testing with Begin/EndUpdate before. When I just put them around the while-loop in the above code, the result is an empty grid. As far as I understood (please correct me if I am wrong) BeginUpdate stores some information about some grid states, disables refresh and redraw and finally deletes the whole grid. EndUpdate restores the saved states, enables refresh and redraw and then redraws the grid. That means I have to rebuild my whole dialog inside a Begin/EndUpdate-block instead of just inserting or deleting a number of items into resp. from the existing dialog. Maybe this is an item for the wish-list: Implement a function that locks grid refreshing and redrawing during a bunch of insertion or removal operations without the need to rebuild the whole dialog. Bye Holger PS: I have forgotten in my first post: Happy New Year! |
||
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
|
oh, right, it deletes content.
ok, try this
wndGrid.GetGridView().m_nLockUpdate = 1;
wndGrid.GetGridView().SetRedraw(FALSE); wndGrid.GetGridView().m_nLockUpdate = 0; wndGrid.GetGridView().SetRedraw(FALSE); |
||
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
||
farr02
Groupie Joined: 10 May 2005 Status: Offline Points: 51 |
Post Options
Thanks(0)
|
|
Hi Oleg,
doesn't work It leads to an access violation in CXTPPropertyGridView::_RefreshIndexes(). I have tried to eliminate the call to Refresh in the CXTPPropertyGridItem::Remove function but that gives me other errors. So I think for the moment it is the best to stay with the current situation and hope for one of the next releases. Or do you have a better idea? Thank you yery much. Bye Holger |
||
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
|
Hi,
Think also you need call Refresh() in the end. (after SetRedraw(FALSE))
|
||
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
||
farr02
Groupie Joined: 10 May 2005 Status: Offline Points: 51 |
Post Options
Thanks(0)
|
|
Hello Oleg,
doesn't work either:-( I uploaded two files regarding the access violation: Number one ( uploads/20080107_042735_CJ_Fhut.zip ) is a crash dump file saved with WinDbg (WinDbg command: .dump /mFhut CJ_Fhut.dmp) and the second ( uploads/20080107_043556_ProblemItemRemo.zip )gives you a small description of the functions I inserted to the lib, and some more information about the access violation. Hope it helps. Bye Holger |
||
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
|
Hi,
Last version to try: :)
void BeginUpdate()
{ GetGridView().m_nLockUpdate = 1; GetGridView().SetRedraw(FALSE); GetGridView().().ResetContent();
} void EndUpdate()
{ GetGridView().m_nLockUpdate = 0; GetGridView().SetRedraw(TRUE); Refresh();
} Think it will work fine.
|
||
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
||
farr02
Groupie Joined: 10 May 2005 Status: Offline Points: 51 |
Post Options
Thanks(0)
|
|
Hi Oleg,
your are right: The code works fine. Thank you very much. Bye Holger |
||
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |