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 

FindRow(object item) == null

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



Joined: 28 Oct 2005
Posts: 2

PostPosted: Fri Oct 28, 2005 9:26 am    Post subject: FindRow(object item) == null Reply with quote

Hello,
this function doesn't work and return null, though I can find this object attached to one of the rows.
Can you help me ? I have the latest version of Virtual Tree.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Fri Oct 28, 2005 11:30 am    Post subject: Reply with quote

Have you read the section in the online help called "Working with Rows"? For this method to work you need to have set up the Parent property (or handled the GetParent event/method for programmatic binding). This enables VirtualTree to uniquely locate a row based on the object identity. If you haven't done this or there is some other problem Virtual Tree will print out a diagnostic message to the Output window to help you track down what the problem might be. So run your project in the debugger and check the output window.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Canavaro



Joined: 28 Oct 2005
Posts: 2

PostPosted: Fri Oct 28, 2005 12:04 pm    Post subject: Reply with quote

This code finds target row:

Code:

        Row FindRow(Row root_row, object item)
        {
            if (root_row.Item == null)
                return null;

            if (root_row.Item.Equals(item))
                return root_row;

            IList childs = root_row.ChildItems;
            if (childs == null || childs.Count == 0)
                return null;

            for (int i = 0; i < childs.Count; i++)
            {
                Row r = FindRow(root_row.ChildRowByIndex(i), item);
                if (r != null)
                    return r;
            }
            return null;
        }
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Fri Oct 28, 2005 10:54 pm    Post subject: Reply with quote

Yes - but its expensive because it requires a full depthwise search of the tree. The VirtualTree method uses the Parent property to construct a "path" to the given item from the root row. It then uses the IndexOf method of the child object collection to locate the index of each item within its parent. If IndexOf is implemented as a simple linear search then this will perform the same as your method. But many collections implement a more efficient algorithm for IndexOf (by indexing items using some form of Hashtable) allowing the location algorithm to be much more efficient.
_________________
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