473,545 Members | 2,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Double Click in treeView

Is there a way to avoid the default action of TreeNode expansion/contraction
caused by double click? I can add an event handler to pop up my properties
dialog on double click, but it has the unintended side-effect of toggling
the expansion of that subtree.

Thanks in advance,
Brian
Nov 15 '05 #1
6 20047

Hi Brian,

I think you can subclass this control and do any operation before the
default procedure.
For example, in the WM_LBUTTONDBLCL K message, you can block the the
processing and return.

HTH.

Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Brian Smith" <br****@cmicro. com>
| Subject: Double Click in treeView
| Date: Mon, 18 Aug 2003 17:40:02 -0700
| Lines: 9
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <uZ************ **@tk2msftngp13 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
| NNTP-Posting-Host: watchguard.cmic ro.com 198.107.63.34
| Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!tk2 msftngp13.phx.g bl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1772 74
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
|
| Is there a way to avoid the default action of TreeNode
expansion/contraction
| caused by double click? I can add an event handler to pop up my
properties
| dialog on double click, but it has the unintended side-effect of toggling
| the expansion of that subtree.
|
| Thanks in advance,
| Brian
|
|
|

Nov 15 '05 #2
So, you're saying that there is no way to do this without subclassing the
control? I was hoping to avoid that.

"Jeffrey Tan[MSFT]" <v-*****@online.mi crosoft.com> wrote in message
news:qh******** ******@cpmsftng xa06.phx.gbl...

Hi Brian,

I think you can subclass this control and do any operation before the
default procedure.
For example, in the WM_LBUTTONDBLCL K message, you can block the the
processing and return.

HTH.

Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Nov 15 '05 #3

Hi Brian,

You also can override the treeview control's wndproc method and process the
WM_LBUTTONDBLCL K
message.
The actual value of the const WM_LBUTTONDBLCL K can be retrieved in "API
text viewer" followed by
Visual Studio 6.0

For example:

using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Data;

namespace treeview
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows. Forms.Form
{
public const int WM_LBUTTONDBLCL K = 0x203;
private newtreeview treeView1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.Containe r components = null;
class newtreeview: TreeView
{
protected override void WndProc(ref Message m)
{
switch(m.Msg )
{
case WM_LBUTTONDBLCL K:
MessageBox.Show ("db click");
return;
break;
}
base.WndProc (ref m);
}
}

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeCompo nent();

//
// TODO: Add any constructor code after InitializeCompo nent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.treeView1 = new newtreeview();
this.SuspendLay out();
//
// treeView1
//
this.treeView1. ImageIndex = -1;
this.treeView1. Location = new System.Drawing. Point(40, 32);
this.treeView1. Name = "treeView1" ;
this.treeView1. Nodes.AddRange( new System.Windows. Forms.TreeNode[] {
new System.Windows. Forms.TreeNode( "Node0", new
System.Windows. Forms.TreeNode[] {
new
System.Windows. Forms.TreeNode( "Node4", new System.Windows. Forms.TreeNode[] {
new
System.Windows. Forms.TreeNode( "Node5")})} ),
new System.Windows. Forms.TreeNode( "Node1", new
System.Windows. Forms.TreeNode[] {
new
System.Windows. Forms.TreeNode( "Node6", new System.Windows. Forms.TreeNode[] {
new
System.Windows. Forms.TreeNode( "Node8")}),
new
System.Windows. Forms.TreeNode( "Node7")}),
new System.Windows. Forms.TreeNode( "Node2"),
new System.Windows. Forms.TreeNode( "Node3")});
this.treeView1. SelectedImageIn dex = -1;
this.treeView1. Size = new System.Drawing. Size(208, 208);
this.treeView1. TabIndex = 0;
//
// Form1
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(292, 266);
this.Controls.A dd(this.treeVie w1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayo ut(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run (new Form1());
}
}
}

HTH.

Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Brian Smith" <br****@cmicro. com>
| References: <uZ************ **@tk2msftngp13 .phx.gbl>
<qh************ **@cpmsftngxa06 .phx.gbl>
| Subject: Re: Double Click in treeView
| Date: Tue, 19 Aug 2003 09:26:27 -0700
| Lines: 22
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <Op************ **@TK2MSFTNGP12 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
| NNTP-Posting-Host: watchguard.cmic ro.com 198.107.63.34
| Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP12.phx.g bl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1774 88
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
|
| So, you're saying that there is no way to do this without subclassing the
| control? I was hoping to avoid that.
|
| "Jeffrey Tan[MSFT]" <v-*****@online.mi crosoft.com> wrote in message
| news:qh******** ******@cpmsftng xa06.phx.gbl...
| >
| > Hi Brian,
| >
| > I think you can subclass this control and do any operation before the
| > default procedure.
| > For example, in the WM_LBUTTONDBLCL K message, you can block the the
| > processing and return.
| >
| > HTH.
| >
| > Jeffrey Tan
| > Microsoft Online Partner Support
| > Get Secure! - www.microsoft.com/security
| > This posting is provided "as is" with no warranties and confers no
rights.
|
|
|
|

Nov 15 '05 #4
Thank you. I have already done this and it works well. It is, however, odd
that this double-click behavior is not optional.
You also can override the treeview control's wndproc method and process the WM_LBUTTONDBLCL K message.
The actual value of the const WM_LBUTTONDBLCL K can be retrieved in "API
text viewer" followed by Visual Studio 6.0

Nov 15 '05 #5

Hi Brian,

What does your "optional" mean?
Do you mean that the double click message is not an optional event that can
be handle?

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Brian Smith" <br****@cmicro. com>
| References: <uZ************ **@tk2msftngp13 .phx.gbl>
<qh************ **@cpmsftngxa06 .phx.gbl>
<Op************ **@TK2MSFTNGP12 .phx.gbl>
<34************ **@cpmsftngxa06 .phx.gbl>
| Subject: Re: Double Click in treeView
| Date: Wed, 20 Aug 2003 11:04:08 -0700
| Lines: 10
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#s************ **@TK2MSFTNGP10 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
| NNTP-Posting-Host: watchguard.cmic ro.com 198.107.63.34
| Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1778 51
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
|
| Thank you. I have already done this and it works well. It is, however,
odd
| that this double-click behavior is not optional.
|
| > You also can override the treeview control's wndproc method and process
| the
| > WM_LBUTTONDBLCL K message.
| > The actual value of the const WM_LBUTTONDBLCL K can be retrieved in "API
| > text viewer" followed by Visual Studio 6.0
|
|
|

Nov 15 '05 #6

Hi Brian,

Thank you for your post.
I understand your meaning.
You believe that the treeview control should not be expend behavior when
double click by default.
But I think in most treeview control in windows software, its double click
behavior is expend and this
behavior fits for the user's convention.
The different behavior in outlook and VS.net is special, so the treeview
control provides wndproc can
be overrride to change the default behavior.

May be, we are just different on opinion, you can give this suggestion to
microsoft at:
http://register.microsoft.com/mswish/suggestion.asp
Thank you for your suggestion.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Brian Smith" <br****@cmicro. com>
| References: <uZ************ **@tk2msftngp13 .phx.gbl>
<qh************ **@cpmsftngxa06 .phx.gbl>
<Op************ **@TK2MSFTNGP12 .phx.gbl>
<34************ **@cpmsftngxa06 .phx.gbl>
<#s************ **@TK2MSFTNGP10 .phx.gbl>
<ZN************ **@cpmsftngxa06 .phx.gbl>
| Subject: Re: Double Click in treeView
| Date: Thu, 21 Aug 2003 15:33:38 -0700
| Lines: 15
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <uI************ **@tk2msftngp13 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
| NNTP-Posting-Host: watchguard.cmic ro.com 198.107.63.34
| Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!tk2 msftngp13.phx.g bl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1783 78
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
|
| > What does your "optional" mean?
| > Do you mean that the double click message is not an optional event that
| can
| > be handle?
|
| I mean the action of toggling the expanded state of the currently selected
| node is not optional. Whenever a double click event happens, the node
under
| the mouse cursor is expanded or collapsed. This is not what I expect
from a
| TreeView. Does Outlook Express do that for the treeview of news posts?
No.
| Does Visual Studio do that for the treeviews for the explorers (solution,
| class, resource, etc...) on the right-hand side? No. Simply, it is
| non-standard behavior when integrating the TreeView control into a UI.
So,
| I am surprised that Microsoft made it difficult to overide this behavior.
|
|
|

Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4640
by: Saradhi | last post by:
I am facing a problem with the TreeView in C#. Whenever I double click on a TreeNode, I am opening another form. This works fine. But the Treenode is getting expanded and collpased whenever I double click on that TreeNode. Is there anyway to stop the expand/collapse bahaviour on the double click of a tree Node?? -SARADHI
1
1583
by: Boni | last post by:
Dear all, I have a question about TreeView elements. is it possible to differentate double click on TreeNode itself from double click on "+" of this TreeNode? Thanks in advance, Boni
1
5358
by: HS1 | last post by:
Hellow all Could you please tell me how to do if I want to print (using console) any node in a TreeView when I "double" click a node (in a Windows application). I tried to use TreeViewAfterSelect event, However, it is not good as it is single click. Thanks SH1
0
859
by: Boni | last post by:
Dear all, I have a question about TreeView elements. is it possible to differentate double click on TreeNode itself from double click on "+" of this TreeNode? Thanks in advance, Boni
3
3576
by: Techsatish | last post by:
how to make a mouseup event called only once during a double click event? here double click is made on a tree node in a tree control. I have the code inside mouseup event....in runtime the mouseup is called twice for the mouse double click over the selected tree node. I want mouseup event to be called onece Any ideas?
0
2408
by: jim | last post by:
Hi, I have a TreeView control that sits on the MasterPage. All of my other webpages inherit from that Master Page. The Treeview receives it's data using an XMLDataSource that has it's DataFile property set to the Web.sitemap file. I have turned off the Expand/Collapse icons on the Treeview. I want to be able to single click a node in...
2
4252
by: Ed Dror | last post by:
Hi there, Based on Microsoft ASP.NET SDK treeview control binding to northwind database (Categoried, Products) I added the following code Protected Sub TreeView1_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.SelectedNodeChanged Me.TreeView1.SelectedNode.NavigateUrl =...
2
11535
by: ykhamitkar | last post by:
Hi there, I have an ms access form and have used treeview within it. When somebody double clicks on the node it opens a separete window for the information of that Node. But due to default setting treeview automatically Expands ot Contracts for that that node. What I want to do is once double click it should show the new form but should...
0
1673
by: Navid | last post by:
Hello, I have a tree view which has Check Box's beside each node. In the BeforeCheck event Handler I have canceled the event to prevent the user from Checking/ Un-checking the box: private void treeView3_BeforeCheck(object sender, TreeViewCancelEventArgs e) { e.Cancel = true; } I am trying to now set up the DoubleClick event but the first...
0
7656
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. ...
0
7805
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...
0
7752
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5969
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...
1
5325
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...
0
3449
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1878
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
1
1013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.