0

I'm working with application, which use TreeView. I want some nodes have checkBoxes, but not all. I know that I can do:

 treeView.CheckBoxes = true; 

But then all nodes have checkBox. How can I add checkBox only for selected nodes?

1

2 Answers 2

1

Looking at the TreeNode class it seems you'll have to implement a custom OnDrawNode function and perform some Tag manipulation.

An example: http://social.msdn.microsoft.com/forums/en-US/winforms/thread/9fbc737b-8385-4285-aa80-0e4602ff5b9b/

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

Comments

0

You need to make a new template for your treeviewitem, or your dataitems.

Something like this:

<Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <CheckBox Grid.Column="0" x:Name="checkBox" Visibility="Hidden"/> <ContentPresenter Grid.Column="1"/> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter TargetName="checkBox" Property="Visibility" Value="Visible"/> </Trigger> </ControlTemplate.Triggers> 

edit: Obviously, this is for WPF. If you are using WinForms, then this will not be of any help. Sorry.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.