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 

edit object for selected rows

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



Joined: 11 Apr 2008
Posts: 67

PostPosted: Tue Mar 24, 2009 11:46 pm    Post subject: edit object for selected rows Reply with quote

I am using object binding for my tree.
I can find in many places how to get the row and object for a given selected row, but how do I update back?

So I get the row with vtTree.SelectedRows[0] lets say.
Then I cast row.item to object type I am binding to.
Then I run a method on the object that updates itself in certain ways.
How do I shove the object back into the tree source?

I thought it would be so simple but row.item is read only.
I know how to get the trail of rows back to the source, but how do I modify the object behind the row?
This must be simple but I cannot find how to do it.
thx
_________________
James M
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Mar 25, 2009 5:07 am    Post subject: Reply with quote

It depends whether you are trying to replace the object that the row represents or simply want to update some of the properties of the object and have the tree update its display. For the latter case you can simply call VirtualTree.UpdateRowData after changing the properties. If you want to replace the item with a completely different item then you need to call Row.UpdateChildren on the parent row and supply the new item as part of the parent items child collection.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
jmaeding



Joined: 11 Apr 2008
Posts: 67

PostPosted: Wed Mar 25, 2009 4:09 pm    Post subject: Reply with quote

its the latter case, here is my code:
Code:

foreach (Infralution.Controls.VirtualTree.Row row in refDvtTree.SelectedRows) {
                XreVDwg xdwg = row.Item as XreVDwg;
                if (xdwg != null && xdwg.IsXreffedChecked == false) {
                    //have the object update itself
                    xdwg.UpdateIsXreffed(Prog.DsAll);
                    //should update VTree source with revised xdwg object
                    row.item = xdwg //does not work of course
                    //now update row
                    refDvtTree.UpdateRowData(row);
                }
            }


I am missing the step of updating the source.

I think the problem is due to the fact that I cannot walk through the source object, as the children are not contained in some property of my XreVDwg objects. I currently override GetChildrenForRow which returns the list of children for a given object, and only the tree stores this. Maybe I need to chgange that. Its one thing to have editors in the tree change the data, but if I want to do it without them, I must have a way to walk through my objects.

Am I on the right track with storing the kids in the object, not just the tree?
_________________
James M
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Mar 25, 2009 8:52 pm    Post subject: Reply with quote

The code you have posted should work - assuming that the UpdateXreffed is changing some property of xdwg that is displayed in the tree. Rather than calling refDvtTree.UpdateRowData(row) for each row inside the loop it would probably be more efficient to call refDvtTree.UpdateRowData() after the loop. The parameterless version updates all displayed rows.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
jmaeding



Joined: 11 Apr 2008
Posts: 67

PostPosted: Wed Mar 25, 2009 10:51 pm    Post subject: Reply with quote

got it, thanks so much for replying as a lot of work hinges on redoing things.
I'll doublecheck my debugging to see why I missed that.

By the way, the tree is working really well for 90% of the program.
I have written what I would call an Explorer "extender" that uses a database to supplement info about files. I could adapt it to any kind of data really. It will make renaming dwg files much easier, as the program knows how to fix all the links that other files have to eachother.
thx
_________________
James M
Back to top
View user's profile Send private message
jmaeding



Joined: 11 Apr 2008
Posts: 67

PostPosted: Wed Mar 25, 2009 11:34 pm    Post subject: Reply with quote

it does work of course.
I had skipped a step that made me think I was updating things wrong.
Your reponse helped immensely.
_________________
James M
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