View previous topic :: View next topic |
Author |
Message |
fx Guest
|
Posted: Wed May 18, 2005 11:25 am Post subject: Problems with FindRow method |
|
|
Hi,
I'am newbie with Virtual Tree Component and I try to use FindRow(item) method and can't get it to work, except for the "root" row. The idea is to be able to expand tree down to a specific row, searched by user from different criteria.
I created a class that inherits VirtualTree and overriden method getParentForItem. In my data object bind to each row, I overriden
Equals method to control exactly how to compare two objects, thinking it could be the problem. In debugger, I see these methods are called for each parent nodes up to root one but finally the method findRow only returns null and I can't figure why.
I did not declared any bindings with ObjectBinding class, just overriden GetChildrenForRow. Hope it's enough to build the tree.
Could someone tell me if there is another "trick" to make it work or explain me how exactly the findRow method compares data objects to get the right row ?
Thanks a lot in advance,
Francois-Xavier |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed May 18, 2005 11:06 pm Post subject: |
|
|
Whenever you override the Equals method for an object you should also override the GetHashCode method so that objects that are equal return the same hash code. If you don't then many collections will not behave as expected. This may be the problem. To track down the problem with FindRow ensure that SuppressErrorMessages property is set to false and check the VisualStudio output window after FindRow is called. If FindRow fails it prints diagnostic information to the output window.
FindRow works by constructing a "path" of objects relative to (but not including) the root row using the GetParentForItem method. It then calls the FindRow(IList path) method to actually find the row. So if you are still having problems try constructing the path yourself and call FindRow(IList path). _________________ Infralution Support |
|
Back to top |
|
|
fx Guest
|
Posted: Thu May 19, 2005 7:52 am Post subject: Find(row) now works |
|
|
Hi,
Thanks a lot for this advice. I overriden Find(IList) to see what's happening. Found that the "root" data object was not aded in the path... Don't know why at the time.
I manually added the root object at first in the collection and now Find() returns the right row !
Thanks a lot |
|
Back to top |
|
|
|