BeginUpdate not working for 2nd TreeView

  • Thread starter Thread starter Etienne
  • Start date Start date
E

Etienne

Hi, I have a form containing 2 TreeViews. When I click on a button, items
are transfered from the left tree to the right tree, which causes
flickering. In order to remove such flickering, I surrounded code with
BeginUpdate/EndUpdate for both trees. The left tree doesn't flicker anymore,
but the right one still does!! Even if I call BeginUpdate/EndUpdate on the
right tree only, it still flickers. What's going on here? Is BeginUpdate
working only for the first TreeView of a form or what?

Thanks for your help!
Etienne
 
Only once, in the Button.Click event. BeginUpdate is the first line and
EndUpdate the last line..BeginUpdate isn't ever called before. Also, I
disabled XP Theme just to be sure this isn't the problem.

Etienne
 
what does the transfer proces look like? are you taking a node out of the
left tree and then put that node into the right tree and then loop? or are
you copying a node from the left tree, putting it into the right tree, then
loop and finally removing all nodes from the left tree? is there a
difference between the two methods with respect to flicker?
 
I found where the problem is. Whenever I edit the text of an existing node,
it causes the tree to redraw even if BeginUpdate was called. Here's a sample
code to reproduce the problem :

destTree.BeginUpdate();
TreeNode n = null, p = null;
for (int i=0; i<50; i++) {
p = n;
n = destTree.Nodes.Add("test");
if (p != null) // If you comment those 2 lines, it no longer redraws.
p.Text = "*" + p.Text;
}
destTree.EndUpdate();

This causes the treeview to redraw for every item. Any idea for a
work-around? I tried subclassing and blocking WM_PAINT (0xF) after
BeginUpdate is called, but this doesn't solve the problem.

Etienne
 
This article doesn't solve my problem, but I tried blocking both WM_PAINT
and WM_ERASEBKGND. There is not much flickering anymore! The scrollbars
still flicker, but at least not the content. Is there a way to stop
redrawing of scrollbars?

Etienne
 
Back
Top