Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The correct way to unselect all rows?

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
Mike.Tabaczynski



Joined: 16 Nov 2010
Posts: 2

PostPosted: Wed Mar 23, 2011 1:25 pm    Post subject: The correct way to unselect all rows? Reply with quote

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
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Mar 23, 2011 11:58 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group