TreeView flicker on changing Node.BackColor

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there any way to control the flicker that occurs when an idividual node's
BackColor property is changed in a treeview? It appears that the entire
control is invalidated and redrawn. How can I invalidate only the node that
has the background color changing?
 
wgillin said:
Is there any way to control the flicker that occurs when an idividual
node's BackColor property is changed in a treeview? It appears that
the entire control is invalidated and redrawn. How can I invalidate
only the node that has the background color changing?

You could try
treeview.BeginEdit();
// your code here
treeview.EndEdit();

though I found this to look slower in many occasions, for the most
part because it won't show any changes until all edits are done, which
gives the feeling nothing happens, and with live updates it might
appear faster.

I just change the back color without begin/end edit and don't
experience flickering.

Frans

--
 
Frans said:
You could try
treeview.BeginEdit();
// your code here
treeview.EndEdit();

This of course should have been BeginUpdate() and EndUpdate(). Sorry
for that :)

FB
 
Thanks Frans. I tried this but the entire control is still invalidated. The
code I am using to toggle the background is:

this.FlaggedNode.BackColor = Color.FromName("Highlight");
this.FlaggedNode.ForeColor = Color.FromName("Window");

Where FlaggedNode is an extended property of the TreeView similar to
SelectedNode.

The method to change the color is only getting called once while the cursor
is over the FlaggedNode so it's not a bug with calling the method. For some
reason the entire control is invalidated rather than the node rect and I
can't figure out how to override this.
 
wgillin said:
Thanks Frans. I tried this but the entire control is still
invalidated. The code I am using to toggle the background is:

this.FlaggedNode.BackColor = Color.FromName("Highlight");
this.FlaggedNode.ForeColor = Color.FromName("Window");

Where FlaggedNode is an extended property of the TreeView similar to
SelectedNode.

The method to change the color is only getting called once while the
cursor is over the FlaggedNode so it's not a bug with calling the
method. For some reason the entire control is invalidated rather
than the node rect and I can't figure out how to override this.

If FlaggedNode is just a TreeNode object, then I don't know what's
happening. I use the same code as you and no flickering.

Frans

--
 
Back
Top