This is a migrated thread and some comments may be shown as answers.

How to select checked treeview item?

2 Answers 141 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ruth
Top achievements
Rank 1
Ruth asked on 22 Feb 2012, 10:23 PM
If I click on a checkbox, it does not select a treeview item. How to programmatically select it?

2 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 23 Feb 2012, 04:53 PM
Hi Ruth,

Thank you for contacting us. You can use the Checked and Unchecked events of RadTreeView:

<telerik:RadTreeView IsTriStateMode="True" IsOptionElementsEnabled="True" ItemsOptionListType="CheckList"
        Checked="RadTreeView_Checked" SelectionMode="Multiple" Unchecked="RadTreeView_Unchecked">
    <telerik:RadTreeViewItem Header="Root">
        <telerik:RadTreeViewItem Header="Child #1" />
        <telerik:RadTreeViewItem Header="Child #2" />
        <telerik:RadTreeViewItem Header="Child #3" />
    </telerik:RadTreeViewItem>
</telerik:RadTreeView>

private void RadTreeView_Checked(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    RadTreeViewItem checkedItem = e.OriginalSource as RadTreeViewItem;
    if (checkedItem != null)
    {
        checkedItem.IsSelected = true;
    }
}
 
private void RadTreeView_Unchecked(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    RadTreeViewItem checkedItem = e.OriginalSource as RadTreeViewItem;
    if (checkedItem != null)
    {
        checkedItem.IsSelected = false;
    }
}

Give it a try and let me know if it works. I'd be glad to further assist you.

Greetings,
Kiril Stanoev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Ruth
Top achievements
Rank 1
answered on 28 Feb 2012, 09:09 PM
Works great, thank you!
Tags
TreeView
Asked by
Ruth
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Ruth
Top achievements
Rank 1
Share this question
or