C# treeview 加号(减号)只让控件打开或者关闭节点,不让触发NodeMouseClick事件
3个回答
展开全部
private void tvList_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
bIsRightClick = false;
}
else if (e.Button == MouseButtons.Right)
{
bIsRightClick = true;
}
//下面这一句是重点,当点击前面的+-时e.X<e.Node.Bounds.X
if (e.X>e.Node.Bounds.X)
{
tvList.SelectedNode = e.Node;
selectedNode = e.Node;
pathNow = new DirectoryInfo(e.Node.Tag.ToString());
if (pathNow.Extension.ToUpper() == ".DWG")
{
NowFile = pathNow;
tvList.ContextMenuStrip = RightMenuFile;
if (!bIsRightClick)
{
if (isFolderClick)
{
InputBlock();
}
blockViewer.LoadDwg(pathNow.FullName);
}
}
else
{
if (!bIsRightClick)
{
Expand(selectedNode);
}
tvList.ContextMenuStrip = RightMenuFolder;
InputImage();
lblFolderName.Visible = true;
tbFolderName.Visible = true;
}
SetImage(root);
}
}
{
if (e.Button == MouseButtons.Left)
{
bIsRightClick = false;
}
else if (e.Button == MouseButtons.Right)
{
bIsRightClick = true;
}
//下面这一句是重点,当点击前面的+-时e.X<e.Node.Bounds.X
if (e.X>e.Node.Bounds.X)
{
tvList.SelectedNode = e.Node;
selectedNode = e.Node;
pathNow = new DirectoryInfo(e.Node.Tag.ToString());
if (pathNow.Extension.ToUpper() == ".DWG")
{
NowFile = pathNow;
tvList.ContextMenuStrip = RightMenuFile;
if (!bIsRightClick)
{
if (isFolderClick)
{
InputBlock();
}
blockViewer.LoadDwg(pathNow.FullName);
}
}
else
{
if (!bIsRightClick)
{
Expand(selectedNode);
}
tvList.ContextMenuStrip = RightMenuFolder;
InputImage();
lblFolderName.Visible = true;
tbFolderName.Visible = true;
}
SetImage(root);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
是不是想实现点击加减号实现展开收缩,不触发单击事件,而单击文字时触发单击事件?
这种情况还是不要用NodeMouseClick事件,用 AfterSelect 事件就可以实现
这种情况还是不要用NodeMouseClick事件,用 AfterSelect 事件就可以实现
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询