Hello,
I'm trying to add an item to the top of my treeview with a value of "Select/Deselect All" that will check all items. I have a treeview named "tvDirectory"
I added it like this:
Then I tried to implement the functionality in the Checked eventhandler like this:
But I get an "object reference not set to instance of an object for "item". Help please, thanks.
I'm trying to add an item to the top of my treeview with a value of "Select/Deselect All" that will check all items. I have a treeview named "tvDirectory"
I added it like this:
tvDirectory.Items.Add(
"Select/Deselect All"
);
Then I tried to implement the functionality in the Checked eventhandler like this:
RadTreeViewItem item = (RadTreeViewItem)((RadTreeView)sender).SelectedContainer;
if
(item !=
null
)
{
if
(item.CheckState == ToggleState.On)
{
foreach
(RadTreeViewItem tvItem
in
tvDirectory.Items)
{
tvItem.CheckState = ToggleState.On;
}
}
else
{
foreach
(RadTreeViewItem tvItem
in
tvDirectory.Items)
{
tvItem.CheckState = ToggleState.Off;
}
}
}
But I get an "object reference not set to instance of an object for "item". Help please, thanks.