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 

Selecting Multiple Items Programmatically

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



Joined: 12 Dec 2007
Posts: 78

PostPosted: Mon Nov 03, 2008 4:11 pm    Post subject: Selecting Multiple Items Programmatically Reply with quote

I have a virtual tree which uses object binding.

The tree allows a copy/paste feature which allows one object to be in the tree in two places at the same time.

When the user selects reference 1 in the tree, I would like to also select reference 2. Thus they would both be highlighted in the tree.

Is there a way this can be done?

Greg
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Nov 03, 2008 10:37 pm    Post subject: Reply with quote

Yes - handle the SelectionChanged event. Then locate the Row for the second item using one of the FindRow or FindRowByIndex methods. Then call virtualTree.SelectedRows.Add() to add the row to the selection.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
gregoryagu



Joined: 12 Dec 2007
Posts: 78

PostPosted: Tue Nov 04, 2008 3:11 pm    Post subject: Reply with quote

The FindRow(object) method finds the first row to match. But if there are two of the same object, it will not find the second one, only the first. So if the user selects the second object, it will find the first, and then both are highlighted.

But if the user selects the first one, the second one is not found. And if there was a 3rd or a 4th, these would not be found either.

Greg
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Nov 04, 2008 9:29 pm    Post subject: Reply with quote

Yes you would need to use the overloaded version of FindRow(IList) or use FindRowByIndex. These allow you to specify the full path to the item.

You should consider whether you really want to do this. If both items are always selected together it means that the user won't be able to select one item and move it to another location or delete it. So once they create the aliasing using copy/paste they are stuck with it.

An alternative way of highlighting the aliased row (without actually selecting it) would be to create a custom RowWidget/CellWidget and override the GetActiveStyle methods - something like:

Code:
 public override Style GetActiveStyle()
 {
    if (Row.Selected)
        return base.GetActiveStyle();
     else
     {
        foreach (Row row in Tree.SelectedRows)
        {
            if (row.Item.IsEqual(Row.Item))
                return GetSelectedStyle();
        }
     }
     return base.GetActiveStyle();
 }

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
gregoryagu



Joined: 12 Dec 2007
Posts: 78

PostPosted: Tue Nov 18, 2008 7:28 pm    Post subject: Reply with quote

OK, thanks for the suggestions.

Greg
Back to top
View user's profile Send private message
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