How to take off the minus button of a TreeNode?

  • Thread starter Thread starter osmarjunior
  • Start date Start date
O

osmarjunior

I want to prevent a TreeNode to be collapsed, so I do the following, in
the BeforeCollapse event:

// Verify if it is the root node
if (e.Node.Name == "0")
e.Cancel = true;

It works ok, but is there a way to not display the minus button?

Regards.

Junior.
 
Hi,
You can set the property "showplusminus" to false to hide ALL the plus
and minus signs,

HTH,
James.
 
Hi again,
A better way to test if it is the root would be

if (e.Node == ((TreeView)sender).Nodes[0])

Cheers,
James.
 
Actually, I just wanna take off the minus button from the first node,
not from all nodes.
But your answer has taken me to another property of the TreeView:
ShowRootLines.
I set it to false, and I got what I want.

Thanks.

pigeonrandle escreveu:
Hi again,
A better way to test if it is the root would be

if (e.Node == ((TreeView)sender).Nodes[0])

Cheers,
James.
I want to prevent a TreeNode to be collapsed, so I do the following, in
the BeforeCollapse event:

// Verify if it is the root node
if (e.Node.Name == "0")
e.Cancel = true;

It works ok, but is there a way to not display the minus button?

Regards.

Junior.
 
In which case, i'm glad i couldn't help :o)
Actually, I just wanna take off the minus button from the first node,
not from all nodes.
But your answer has taken me to another property of the TreeView:
ShowRootLines.
I set it to false, and I got what I want.

Thanks.

pigeonrandle escreveu:
Hi again,
A better way to test if it is the root would be

if (e.Node == ((TreeView)sender).Nodes[0])

Cheers,
James.
I want to prevent a TreeNode to be collapsed, so I do the following, in
the BeforeCollapse event:

// Verify if it is the root node
if (e.Node.Name == "0")
e.Cancel = true;

It works ok, but is there a way to not display the minus button?

Regards.

Junior.
 
Back
Top