English 中文(简体)
有哪些东西可以阻止诺德穆塞克事件的发射?
原标题:What could be preventing the NodeMouseClick event from firing?

I m working with a windows form app which I have treeview to show the list of folders , and I have attached NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) event. and on click of node I call server method to populate the treeview. Here I could see that NodeMouseClick for one of my tree node is not at all getting triggered. however for rest of the nodes its working fine with no issues. can anyone tell me what is the exact reason that its not getting triggered. and I dont want to use After_Select event.

public Form1()
    {
        InitializeComponent();
        Init();
    }

    private void Init()
    {
        treeView1.Nodes.Add("root");

        for (int i = 0; i < 23; i++)
        {
            treeView1.Nodes[0].Nodes.Add(i.ToString());
            treeView1.Nodes[0].Nodes[i].Nodes.Add("child" + i.ToString());
        }

        treeView1.Nodes[0].Expand();
    }

使用树木面积=280 369

问题回答

正如我在评论中提到的那样,工作方向是降低视窗A普森的水平,拦截使用电线,并提升点击事件。 该法典很简单,但可以运作。

将以下代码添加到贵项目的新类别(我称之为<代码>)。 Custom:

class CustomTreeView : System.Windows.Forms.TreeView
{
    public event EventHandler<TreeNodeMouseClickEventArgs> CustomNodeClick;

    private const int WM_LBUTTONDOWN = 0x201;

    protected override void WndProc(ref System.Windows.Forms.Message m)
    {
        if (m.Msg == WM_LBUTTONDOWN)  // left mouse button down
        {
            // get the current position of the mouse pointer
            Point mousePos = Control.MousePosition;

            // get the node the user clicked on
            TreeNode testNode = GetNodeAt(PointToClient(mousePos));

            // see if the clicked area contained an actual node
            if (testNode != null)
            {
                // A node was clicked, so raise our custom event
                var e = new TreeNodeMouseClickEventArgs(testNode,
                                 MouseButtons.Left, 1, mousePos.X, mousePos.Y);
                if (CustomNodeClick != null)
                    CustomNodeClick(this, e);
            }
        }

        // call through to let the base class process the message
        base.WndProc(ref m);
    }
}

然后修改所有提及<代码>System.WindowsForms.TreeView的内容。 对新<代码>的控制 您刚刚成立的“习俗评论”()。 这是现有<条码>的下级<>。 如果你不熟悉叙级,这就是我们改变现有功能或取消现有控制的新功能的方法。 在此情况下,我们删除原来的<代码>TreeView的控制,以添加。 化学品编号: 每当我们发现用户点击 no子时,我们就会奋起。

最后,将活动笔记方法改为“<代码>。 化学品编号: 我们再次提出的问题,而不是夸张的<代码>NodeMouseClick 你们试图在事前使用。

编造和操作。 一切工作都应如期进行。

尝试使用<代码> 下午3时30分 活动必须经过任何选择。





相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签