TreeNode is no longer highlighted when TreeView loses focus

B

bg_ie

Hi,

I have a treeview where the user selects a node before editing it. The
problem is that when the user clicks on the text box to edit the node,
the treeview loses its focus and the node is no longer highlighted. To
fix this I do something like -

void treeView_AfterSelect(object sender, EventArgs e)
{
selectedNode.BackColor = Color.White;
selectedNode.ForeColor = Color.Black;

selectedNode = (TreeNodeEx)
((TreeView)sender).SelectedNode;

selectedNode.BackColor = Color.DarkBlue;
selectedNode.ForeColor = Color.White;

textBoxComment.Text = selectedNode.Text;
}

But now my tree view flickers a little... and I don't really like this
implementation anyway. How can I keep the last selected node
highlighted even when the treeview loses its focus?

Thanks,

Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top