473,769 Members | 3,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7387
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**@discussio ns.microsoft.co m> wrote in message
news:B5******** *************** ***********@mic rosoft.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 doneByDoubleCli ck As Boolean = False
Protected Overrides Sub OnDoubleClick(B yVal e As System.EventArg s)
doneByDoubleCli ck = True
End Sub

Protected Overrides Sub OnBeforeExpand( ByVal e As TreeViewCancelE ventArgs)
If doneByDoubleCli ck Then e.Cancel = True
doneByDoubleCli ck = False
End Sub

Protected Overrides Sub OnBeforeCollaps e(ByVal e As
TreeViewCancelE ventArgs)
If doneByDoubleCli ck Then e.Cancel = True
doneByDoubleCli ck = 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 doneByDoubleCli ck As Boolean = False
Protected Overrides Sub OnDoubleClick(B yVal e As System.EventArg s)
doneByDoubleCli ck = True
End Sub

Protected Overrides Sub OnBeforeExpand( ByVal e As TreeViewCancelE ventArgs)
If doneByDoubleCli ck Then e.Cancel = True
doneByDoubleCli ck = False
End Sub

Protected Overrides Sub OnBeforeCollaps e(ByVal e As
TreeViewCancelE ventArgs)
If doneByDoubleCli ck Then e.Cancel = True
doneByDoubleCli ck = 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
1285
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 appear in the underlying collection. However, the user must be able to reorder certain items in the collection--and, hence, the TreeView. I have created a context-sensitive menu that allows the user to move an item in the collection either up or...
0
1813
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 differently. It now has, built in, the ability to have 12 levels, not just 3. The tree's recordsource table (TreeviewRS) is built based on information
4
10140
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 new TreeView with the same nodes ;) So I would like to keep the expanding state of the first Tree for the second one on the next page. At least the last selected node (path will be saved in query string) should be expanded.
1
9982
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 tried getting the selected node and then expanding it in the refreshed tree view using expand() but it does not do it. Thanks for any help.
3
2256
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 child node or a leaf node then a DataGrid is populated based on the node's ID property. If I expand a node then the DataGrid is not populated. This works fine. The problem is that this doesn't work if I collapse the tree. If I collapse the tree...
0
997
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 (!ispostback)" ,but i can not , because i am building the tree all over again each time i am doing post back . Can you please help me with this problem .
0
1249
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 parents and children etc. In this control, the TreeControl does the work, storing Leaves. Collapsing a node involves hiding each leaf in the appropriate collection, and recalculating the lines etc. In the other The tree has one Leaf and it is...
4
6373
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 Treeview to do one of two things: If the double-click was on a top-level node then the default action of exapnding/collapsing the node should be allowed as usual and with no further action.
13
2771
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 400x200… that I want to be able to expand to how much information I put in them…. Just need a code that will cut it off and then OPEN it… So
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10206
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8863
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7403
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.