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" <
[email protected]>
| References: <
[email protected]>
<
[email protected]>
| 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: <
[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: watchguard.cmicro.com 198.107.63.34
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.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.
|
| | >
| > 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.
|
|
|
|