473,387 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
6 7308
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: alanrn | last post by:
I am using a TreeView to display the hierarchy of a strongly-typed collection (inherited from CollectionBase). The order of the nodes in the TreeView is strictly tied to the order in which they...
0
by: Mike Preston | last post by:
Warning - long message. Many thanks for making the A97 version of the treeview w/o activex controls available. I have taken it down a different path and ended up doing almost everything...
4
by: Karim El Jed | last post by:
Hi, I'm trying to expand a special Node of my TreeView from Codebehind. I have a TreeView on a page for navigating to another site. On the other tsite here is the same TreeView more precisely a...
1
by: James L | last post by:
Hi, I have a treeview that has to be refreshed due to data changes. Is it possible to select the last node that they were viewing when the tree view was been populated once again? I have...
3
by: Shawn | last post by:
Hi. I'm working with the TreeView control in my ASP.NET 1.1 application. I have a problem I haven't been able to figure out. When I click on a node (not expand), whether it's a parent node, a...
0
by: rony_16 | last post by:
Hi, i have a problem with the webcontrol treeview in asp.net v2 . i want to save the state of expanding/collapsing of my tree after post back . i know that i can do that if i write "if...
0
by: Stuart Nathan | last post by:
I've written 2 separate TreeView Controls both of which are slow. Each consists of two parts - A Tree and a Leaf. In one the Tree is populated by individual leaves, which are drawn calculating...
4
by: John Dann | last post by:
I'm trying to implement a fairly simple Treeview procedure but running into problems. My Treeview has just two levels of nodes: top-level and one child level. I want a doube-click on the...
13
Chrisjc
by: Chrisjc | last post by:
I am in need of an expanding and collapsing code… The goal is To be able to click a PICTURE IMAGE and expand to show information Reason for this is I have 3 TABLES of information of about ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.