473,385 Members | 1,901 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,385 software developers and data experts.

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 20031

Hi Brian,

I think you can subclass this control and do any operation before the
default procedure.
For example, in the WM_LBUTTONDBLCLK 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.public.dotnet.languages.csharp
| NNTP-Posting-Host: watchguard.cmicro.com 198.107.63.34
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:177274
| X-Tomcat-NG: microsoft.public.dotnet.languages.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.microsoft.com> wrote in message
news:qh**************@cpmsftngxa06.phx.gbl...

Hi Brian,

I think you can subclass this control and do any operation before the
default procedure.
For example, in the WM_LBUTTONDBLCLK 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_LBUTTONDBLCLK
message.
The actual value of the const WM_LBUTTONDBLCLK can be retrieved in "API
text viewer" followed by
Visual Studio 6.0

For example:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
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_LBUTTONDBLCLK = 0x203;
private newtreeview treeView1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
class newtreeview: TreeView
{
protected override void WndProc(ref Message m)
{
switch(m.Msg )
{
case WM_LBUTTONDBLCLK:
MessageBox.Show ("db click");
return;
break;
}
base.WndProc (ref m);
}
}

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

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
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 InitializeComponent()
{
this.treeView1 = new newtreeview();
this.SuspendLayout();
//
// 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.SelectedImageIndex = -1;
this.treeView1.Size = new System.Drawing.Size(208, 208);
this.treeView1.TabIndex = 0;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.treeView1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(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.public.dotnet.languages.csharp
| NNTP-Posting-Host: watchguard.cmicro.com 198.107.63.34
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:177488
| X-Tomcat-NG: microsoft.public.dotnet.languages.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.microsoft.com> wrote in message
| news:qh**************@cpmsftngxa06.phx.gbl...
| >
| > Hi Brian,
| >
| > I think you can subclass this control and do any operation before the
| > default procedure.
| > For example, in the WM_LBUTTONDBLCLK 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_LBUTTONDBLCLK message.
The actual value of the const WM_LBUTTONDBLCLK 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.public.dotnet.languages.csharp
| NNTP-Posting-Host: watchguard.cmicro.com 198.107.63.34
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:177851
| X-Tomcat-NG: microsoft.public.dotnet.languages.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_LBUTTONDBLCLK message.
| > The actual value of the const WM_LBUTTONDBLCLK 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.public.dotnet.languages.csharp
| NNTP-Posting-Host: watchguard.cmicro.com 198.107.63.34
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:178378
| X-Tomcat-NG: microsoft.public.dotnet.languages.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
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...
1
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
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...
0
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
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...
0
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...
2
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...
2
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...
0
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...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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.