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 

Ctrl + MouseUp event

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



Joined: 21 Oct 2006
Posts: 32

PostPosted: Thu Dec 27, 2007 1:19 am    Post subject: Ctrl + MouseUp event Reply with quote

Hi,

I currently have a mouseup event in my app which works fine when I click on the associated virtualtree. However, if I press and hold the control key and then click on the tree the mouseup event will not fire. Do I have to craete a seperate event handler for this? Or is there a way to make the maouseup event handle this?

Thanks,
Waqas
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Dec 27, 2007 10:06 am    Post subject: Reply with quote

Have you added a handler to the VirtualTree.MouseUp event? I've just tested this and the event still fires when the control key is held down. Maybe you could simulate the issue you are having in a simple sample project and email us the zipped project to check out the problem.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
WaqasK



Joined: 21 Oct 2006
Posts: 32

PostPosted: Fri Dec 28, 2007 6:02 pm    Post subject: Reply with quote

Ok, I've realised what the problem is. I have a mouseUp event for the virtual tree that would do 2 things depending on whether any items have been selected when the event fires:

Code:
Private Sub VirtualTree1_Click(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles VirtualTree1.MouseUp
        If VirtualTree1.SelectedItem IsNot Nothing Then
              'Do this
        Else
              'Do somthing else
        End If
 End Sub


What I found initially was that the event would fire when I clicked the mousebutton but not when I used ctrl + click. So I added the code below to see exactly what the value of the Tree.SelectedItems.Count property was when the event was fired:

Code:
Label2.Text = VirtualTree1.SelectedItems.Count.ToString


What I found was if i clicked on a single item the selecteditems count value would change to 1 as expected. Then, when I used ctrl + click on the same item to deselect it the event did fire again (you were right!) but the selecteditems.count value did not change to 0 as it should but remained 1.

So the problem is that the SelectedItems.Count property did not update with the ctrl + click scenario. I copied the code from the mouseUp handler into a SelectionChanged event and ran it again and found that the value of the SelectedItems.Count property did update on ctrl + click.

I am not sure whether this is a bug or not. At the moment we are using a workaround by incorporating both event handlers into our app with mouseup handling the SelectedItems.Count is greater that 0 scenario and selectionchanged handling count is less than or equal to 1.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Fri Dec 28, 2007 9:10 pm    Post subject: Reply with quote

This isn't a bug - but due to the order in when the mouse button events are processed when handling item selection in Virtual Tree. As you have discovered, if you want to do something when the the selection has changed you should handle the SelectionChanged event.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
WaqasK



Joined: 21 Oct 2006
Posts: 32

PostPosted: Sat Dec 29, 2007 5:19 pm    Post subject: Reply with quote

Ok, no problem. We'll continue forward with our current solution. Thanks for the usual great support.

Waqas
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