0
votes

i wanted to create a custom treeview so i inherited the treeview class and created 'CustomTreeView' class

there i implemented multiselect concept..

for making the node as selected,

node.BackColor = SystemColors.Highlight;
node.ForeColor = SystemColors.HighlightText;

i used these lines...

but the problem is when i make the control as disabled(ie enabled=false),

the selected node goes invisible..

any other solution to make a node selected??? without this enabled problem?


EDIT: Here is the full function that is called when a node is selected:

private void ToggleNode(TreeNode node, bool bSelectNode)
{
   if (bSelectNode)
   {
      m_SelectedNode = node;

      if (!m_SelectedNodes.Contains(node))
         m_SelectedNodes.Add(node);

      node.BackColor = SystemColors.Highlight;
      node.ForeColor = SystemColors.HighlightText;
   }
   else
   {
      m_SelectedNodes.Remove(node);
      node.BackColor = this.BackColor;
      node.ForeColor = this.ForeColor;
   }
}
1
Can you show us some of your code? From the way I understand your description, I can't reproduce this problem. A disabled TreeView control still respects the custom BackColor and ForeColor properties set to individual nodes. - Cody Gray
private void ToggleNode(TreeNode node, bool bSelectNode) { if (bSelectNode) { m_SelectedNode = node; if (!m_SelectedNodes.Contains(node)) m_SelectedNodes.Add(node); node.BackColor = SystemColors.Highlight; node.ForeColor = SystemColors.HighlightText; } else { m_SelectedNodes.Remove(node); node.BackColor = this.BackColor; node.ForeColor = this.ForeColor; } } - curiosity
is function will be called when the node is selected - curiosity
and when the application which hav this customtreeview is disabled.. the node's text goes invisible - curiosity
Have you specified a custom BackColor and/or ForeColor for your TreeView? Those could be similar enough to the highlight colors that it's causing them to look invisible. With a standard white BackColor and black ForeColor for my TreeView, combined with my system's green Highlight color and white HighlightText color, I cannot reproduce this behavior. - Cody Gray

1 Answers

1
votes

I suspect it's because Highlight and HighlightText are sufficiently close together that you get this effect with the dimming.

Try Red and Blue. Does it still disappear?