View previous topic :: View next topic |
Author |
Message |
Mike.Tabaczynski
Joined: 16 Nov 2010 Posts: 2
|
Posted: Wed Mar 23, 2011 1:25 pm Post subject: The correct way to unselect all rows? |
|
|
Hi, I have a class derived from VirtualTree with a member function like this:
public void UnselectAllRows()
{
SelectedItems.Clear();
//IList selected = SelectedItems;
//while (selected.Count != 0)
//{
// selected.RemoveAt(selected.Count - 1);
// SelectedItems = selected;
//}
UpdateRows();
}
The uncommented version does not work, Clear() appears to do nothing and the selection remains unchanged. If switch to the commented version, all selected rows will be correctly unselected. Not using that version because the code looks suspicious and produces some unwanted side effects in our application.
What exactly is the correct way to do this?
Thanks
MikeT |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Mar 23, 2011 11:58 pm Post subject: |
|
|
The correct way to do this is:
Code: | public void UnselectAllRows()
{
SelectedRows.Clear();
} |
The SelectedRows property is the collection of Rows that Virtual Tree uses to determine selection. The SelectedItems property is a convenience that allows you to get (or set) the underlying data items that are currently selected. The collection it returns is created dynamically each time the property is called by iterating through the SelectedRows collection and adding the Row.Item object. Changing the collection returned by SelectedItems therefore has no affect on the tree. _________________ Infralution Support |
|
Back to top |
|
|
|