2

Possible Duplicate:
TreeView Remove CheckBox by some Nodes

In my C# Windows Form Application, I have Treeview control with checkboxes.

I want to prevent the user from checking particular nodes' checkboxes. How can stop the user from being able to check particular ones?

3

1 Answer 1

1

TreeView.AfterCheck Event is one option to prevent checking nodes. I find this is an easy way of doing it. But there can be better ways.

private void node_AfterCheck(object sender, TreeViewEventArgs e) { // The code only executes if the user caused the checked state to change. if(e.Action != TreeViewAction.Unknown) { if(e.Node.Nodes.Count > 0) { //Check whether that is a valid checkbox // If not you can uncheck it. } } } 

Edit

To hide the checkboxes. Look at Cody Gray's answer here.

Sign up to request clarification or add additional context in comments.

5 Comments

We dont allow the user to check the check box.While creating that particullar tree node, i want to create the specific tree node with check box disabled.
Why don't you hide checkboxes rather than disabling as you have asked in other question. Again this may help you stackoverflow.com/questions/4826556/…
My thought is exactly what u said...Is this possible?
@ Saravanan : Look at here. This should work. stackoverflow.com/questions/4826556/…
@ Sarvanan : I've updated my answer with the link to Cody Gray's answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.