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 

Collapsed node event?

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





PostPosted: Wed Mar 09, 2005 10:22 pm    Post subject: Collapsed node event? Reply with quote

Is there an event to find out the user collapsed a node in the tree?

The scenario is I need to change selection to the node that is collapsed if the currently selected row is under that node in the tree.

Thanks,

Mark
Back to top
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Mar 10, 2005 5:13 am    Post subject: Reply with quote

There is currently no event to notify you of this (since generally VirtualTree handles obtaining data on demand - which this what the expand/collapse events of other trees are typically used for).

You can however achieve what you want by using the widget framework to change the behaviour of the "ExpansionWidget" (see the section in the online help on "Custom Painting and Mouse Handling" under "Customizing Appearance" for more information)

To do this you derive a new ExpansionWidget class as follows:

Code:

using Infralution.Controls.VirtualTree;
public class MyExpansionWidget : ExpansionWidget
{
        public MyExpansionWidget(RowWidget rowWidget)
           : base(rowWidget)
        {}

        public override void OnMouseDown(MouseEventArgs e)
        {
            RowWidget.OnMouseDown(e);
            base.OnMouseDown (e);
        }
}


This will change the behaviour of the expansion widget so that when you expand/collapse a row that row is selected (since that is the default behaviour of RowWidget.OnMouseDown - we just let it handle it)

Then you inherit from VirtualTree to override the method that creates the expansion widget as follows:

Code:

using Infralution.Controls.VirtualTree;
public class MyVirtualTree : VirtualTree
{
       protected override ExpansionWidget
                CreateExpansionWidget(RowWidget rowWidget)
        {
            return new MyExpansionWidget(rowWidget);
        }
}


If you really feel a Collapse/Expand event is needed let us know and we will consider it for a future release.
_________________
Infralution Support


Last edited by Infralution on Tue Apr 05, 2005 9:01 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Mark Johnson
Guest





PostPosted: Mon Mar 14, 2005 6:23 pm    Post subject: Reply with quote

Thanks for the response.

That's close to what I want.

I specifcally need to only select the collapsed node if the currently selected node is a child of the node being collapsed. So the user has to always have an item selected that is not collapsed. I don't need to do anything on expanding, just collapsing.

Thanks,

Mark
Back to top
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Mar 14, 2005 9:28 pm    Post subject: Reply with quote

You could change the OnMouseDown method to only call the RowWidget.OnMouseDown method if the currently selected row (if any) is a child of the row and the row is expanded eg:

public override void OnMouseDown(MouseEventArgs e)
{
if (this.Row.Expanded)
{
Row selectedRow = Tree.SelectedRow;
if (selectedRow != null && selectedRow.ParentRow == this.Row)
{
RowWidget.OnMouseDown(e);
}
}
base.OnMouseDown (e);
}

This assumes you a using single selection mode. If you are using multiple selection you would need to check each row in the SelectedRows.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Mark Johnson
Guest





PostPosted: Tue Mar 15, 2005 5:59 pm    Post subject: Reply with quote

Thanks for the help.

I end up getting it to work.
Back to top
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