By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,650 Members | 753 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,650 IT Pros & Developers. It's quick & easy.

Treeview and disabling doubleclick from collapsing/expanding tree

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.