467,175 Members | 1,343 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,175 developers. It's quick & easy.

Treeview and disabling doubleclick from collapsing/expanding tree

Hello,

I would like some advice on how to disable the behavior of treeviews to
expand and collapse when double clicked upon, but still allow the user to use
the plus and minus on each node.

Thanks in advance!
Jack

Nov 21 '05 #1
  • viewed: 6868
Share:
6 Replies
Jack wrote:
Hello,

I would like some advice on how to disable the behavior of treeviews to
expand and collapse when double clicked upon, but still allow the user to use
the plus and minus on each node.


I can't see the logic in that. Why prevent doubleclicking when
collapsing the tree is allowed?

--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #2
Thanks for the response and it's a good question. I want double-clicking on a
node to open a data entry form regarding that node. So, i'd like to limit
collapsing and expanding nodes to just the plus and minus signs.
"C-Services Holland b.v." wrote:
Jack wrote:
Hello,

I would like some advice on how to disable the behavior of treeviews to
expand and collapse when double clicked upon, but still allow the user to use
the plus and minus on each node.


I can't see the logic in that. Why prevent doubleclicking when
collapsing the tree is allowed?

--
Rinze van Huizen
C-Services Holland b.v.

Nov 21 '05 #3
I haven't tried this but since nobody responded with an answer I'll lay out
my thinking on it.

You need to inherit your own treeview control and then override the double
click handler. I believe if you don't call the mybase function you
shouldn't get the behavior then.

Just an idea.
Chris
"Jack" <Ja**@discussions.microsoft.com> wrote in message
news:B5**********************************@microsof t.com...
Thanks for the response and it's a good question. I want double-clicking
on a
node to open a data entry form regarding that node. So, i'd like to limit
collapsing and expanding nodes to just the plus and minus signs.
"C-Services Holland b.v." wrote:
Jack wrote:
> Hello,
>
> I would like some advice on how to disable the behavior of treeviews to
> expand and collapse when double clicked upon, but still allow the user
> to use
> the plus and minus on each node.
>


I can't see the logic in that. Why prevent doubleclicking when
collapsing the tree is allowed?

--
Rinze van Huizen
C-Services Holland b.v.

Nov 21 '05 #4
Hi Jack

I think this is the sort of thing you need. Before expanding or collapsing,
it checks whether you've just double clicked on the control. You'll need to
put your open a form logic into the OnDoubleClick override method as well.
Code follows...

HTH

Nigel Armstrong

Class MyTree
Inherits TreeView

Dim doneByDoubleClick As Boolean = False
Protected Overrides Sub OnDoubleClick(ByVal e As System.EventArgs)
doneByDoubleClick = True
End Sub

Protected Overrides Sub OnBeforeExpand(ByVal e As TreeViewCancelEventArgs)
If doneByDoubleClick Then e.Cancel = True
doneByDoubleClick = False
End Sub

Protected Overrides Sub OnBeforeCollapse(ByVal e As
TreeViewCancelEventArgs)
If doneByDoubleClick Then e.Cancel = True
doneByDoubleClick = False
End Sub
End Class

"Jack" wrote:
Thanks for the response and it's a good question. I want double-clicking on a
node to open a data entry form regarding that node. So, i'd like to limit
collapsing and expanding nodes to just the plus and minus signs.
"C-Services Holland b.v." wrote:
Jack wrote:
Hello,

I would like some advice on how to disable the behavior of treeviews to
expand and collapse when double clicked upon, but still allow the user to use
the plus and minus on each node.


I can't see the logic in that. Why prevent doubleclicking when
collapsing the tree is allowed?

--
Rinze van Huizen
C-Services Holland b.v.

Nov 21 '05 #5
Looks like exactly what I'm looking for. Thanks!

"Nigel Armstrong" wrote:
Hi Jack

I think this is the sort of thing you need. Before expanding or collapsing,
it checks whether you've just double clicked on the control. You'll need to
put your open a form logic into the OnDoubleClick override method as well.
Code follows...

HTH

Nigel Armstrong

Class MyTree
Inherits TreeView

Dim doneByDoubleClick As Boolean = False
Protected Overrides Sub OnDoubleClick(ByVal e As System.EventArgs)
doneByDoubleClick = True
End Sub

Protected Overrides Sub OnBeforeExpand(ByVal e As TreeViewCancelEventArgs)
If doneByDoubleClick Then e.Cancel = True
doneByDoubleClick = False
End Sub

Protected Overrides Sub OnBeforeCollapse(ByVal e As
TreeViewCancelEventArgs)
If doneByDoubleClick Then e.Cancel = True
doneByDoubleClick = False
End Sub
End Class

"Jack" wrote:
Thanks for the response and it's a good question. I want double-clicking on a
node to open a data entry form regarding that node. So, i'd like to limit
collapsing and expanding nodes to just the plus and minus signs.
"C-Services Holland b.v." wrote:
Jack wrote:
> Hello,
>
> I would like some advice on how to disable the behavior of treeviews to
> expand and collapse when double clicked upon, but still allow the user to use
> the plus and minus on each node.
>

I can't see the logic in that. Why prevent doubleclicking when
collapsing the tree is allowed?

--
Rinze van Huizen
C-Services Holland b.v.

Nov 21 '05 #6
Jack -

Did you ever get this to work? I want to do the exact same thing, but I
find that the double-click event happens AFTER the beforeexpand events, so
the example does not work.

-zorpy
Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by alanrn | last post: by
reply views Thread by Mike Preston | last post: by
4 posts views Thread by Karim El Jed | last post: by
3 posts views Thread by Shawn | last post: by
reply views Thread by rony_16 | last post: by
reply views Thread by Stuart Nathan | last post: by
4 posts views Thread by John Dann | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.