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.
|
|
|
|