How come the UltraTree control fires a DoubleClick event, when I doubleclick on the scrollbar?
The result is that DoubleClick fires, when a user is scolling up or down, and is clicking a little bit too fast on the up or down arrows.
Is there a way to disable or work around this feature?
Regards,
Jørn
Hi Joesn,
The reason that most controls don't fire events like Click and DoubleClick when the mouse is on the scrollbar is that the scrollbar is provided by a window style is not part of the client area of the control.
In the case of the Infragistics controls, this is not the case. Infragistics controls use an UltraScrollBar, so this allows the scrollbar to be themed and you can apply appearances to them. So they have more functionality than a regular scrollbar.
I thought that there was a NodeDoubleClick event on UltraWinTree, so if you are only concerned with responding to a double-click on a node, you could use that event. If you want to deal with other parts of the tree (or if I am wrong about the existance of that event), then you need to determine what part of the tree the mouse is over. The best way to do this is to use the UIElements of the tree. Do a search in the Infragistics KnowledgeBase for the "ElementFromPoint" method and this will give you a whole bunch of articles that describes how to determine what part of an an Infragistics control is at a point such as the current location of the mouse.
If you can give me some more specifics about exactly what parts of the tree you are concerned with, I can probably give you more detailed info. But it sounds like you need to get the UIElement that the moue is currently over and then call GetAncestor and try to find a ScrollBarUIElement. If you find one, then you will know the mouse is on a scroll bar and you can skip your DoubleClick event logic.
Also, if you are going to be working with UIElements, I recommend getting the UIElementVewer Utility. It's a big help.
http://geekswithblogs.net/devin/archive/2005/11/17/60406.aspx
Hi Mike.
I am only concerned about the vertical scrollbar.
I have a small application with a hierarchy of physical locations. When the user doubleclicks on an item, a new window opens where he can edit the properties of the location. Recently a user complained that the window opened when he tried to scroll through the list. He simply clicked the "up" arrow a lot of times very quickly.The control thinks it is a double-click.
Unfortunately there is no NodeDoubleClick event, so I think I have to do as you say and use the UIElements.
Thank you,Jørn
If you like you can submit a feature request for a NodeDoubleClick event. You could use the code I posted in MouseDoubleClick, and programmatically expnad the node if the hit was not on an expansion indicator.
Thanks for the code samples. I was able to use them to quickly solve most of my current problem, but there's still an issue.
To summarize, I have a tree in grid mode with two bands. The root band forbids selection. Double-clicks expand or collapse a node. The child band allows selection (extended across multiple parents). I want to reserve double-clicking for entering edit mode.
Using the above code, I recognize when to enter edit mode when double-clicking a selected row. It almost always works.
My problem is that, only in the very first child band, if a row isn't already selected, double-clicking it doesn't raise the double-click event, so that I have to double-click again. I experimented with different click speeds, and there's no question that the double-click should be happening but isn't. All other child bands register the first double-click for as-yet-unselected rows.
Any ideas?
I was sloppy in referring to child bands, so here it is again.
Only in the child rows of the first row of the root band, a double-click on an unselected row doesn't raise a double-click event. In child rows of subsequent rows of the root band, the event is fired as expected.
The DoubleClick (and MouseDoubleClick) event is raised by the System.Windows.Forms.Control class, so I have no explanation for why the event would not be raised when the cursor is positioned over certain nodes. I assume you put a breakpoint at the entry point of the event handler and confirmed that the event itself is not firing. If possible, please attach the test project so we can take a look.
I don't have a concise repro scenario to upload at the moment.
Yes, I checked that the event wasn't being fired.
I am handling the AfterSelect event to start a potentially lengthy operation. I thought maybe the double-click timing was getting disturbed with so much time spent on the first click, so I put the time-consuming parts into a timer tick event handler. That fixed most of the problem, which looks increasingly application-specific, so consider it resolved. I'll post again if I run out of ideas.
Thanks for responding so quickly.