//获取鼠标在myTreeView控件按下的次数,并赋给全局变量m_MouseClicks
private void MouseDown(object sender, MouseEventArgs e)
{
this.m_MouseClicks = e.Clicks;
}
//myTreeView控件节点展开之前判断鼠标按下的次数,并进行控制
private void BeforeExpand(object sender, TreeViewCancelEventArgs e)
{
if (this.m_MouseClicks > 1)
{
//如果是鼠标双击则禁止结点展开
e.Cancel = true;
}
else
{
//如果是鼠标单击则允许结点展开
e.Cancel = false;
}
} |