How to take off the minus button of a TreeNode?

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.
 
P

pigeonrandle

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

HTH,
James.
 
P

pigeonrandle

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

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

Cheers,
James.
 
O

osmarjunior

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.
 
P

pigeonrandle

In which case, i'm glad i couldn't help :blush:)
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.
 

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