C#的treeview节点选择

privatevoidSearchTreeView_Load(objectsender,EventArgse){//记录按钮的位置m_ptRptLocation=newP... private void SearchTreeView_Load(object sender, EventArgs e)
{
// 记录按钮的位置
m_ptRptLocation = new Point(btnSearchByTime.Left, btnSearchByTime.Bottom + 3);
m_Loaction[0] = btnSearchByTime.Location;
m_Loaction[1] = btnSearchByDoor.Location;
m_Loaction[2] = btnSearchByUser.Location;
m_Loaction[3] = btnComSearch.Location;
m_Loaction[4] = btnShowAll.Location;
m_Loaction[5] = btnToExcel.Location;
m_Loaction[6] = btnSearch.Location;
btnSearch.Visible = false;
m_btnArray[0] = btnSearchByTime;
m_btnArray[1] = btnSearchByDoor;
m_btnArray[2] = btnSearchByUser;
m_btnArray[3] = btnComSearch;
m_btnArray[4] = btnShowAll;
m_btnArray[5] = btnToExcel;
m_btnArray[6] = btnSearch;
m_btnArray[6].Location = m_Loaction[0];

treeSearch.HideSelection = true;
treeSearch.SelectedNode = treeSearch.Nodes[0];

// 初始化4个报表的位置和大小
rptOpenDoorRecord.Location = m_ptRptLocation;
rptFiRecord.Location = m_ptRptLocation;
rptUserList.Location = m_ptRptLocation;
rptOperateLog.Location = m_ptRptLocation;
rptOpenDoorRecord.Size = m_sizeRpt;
rptFiRecord.Size = m_sizeRpt;
rptUserList.Size = m_sizeRpt;
rptOperateLog.Size = m_sizeRpt;
}
private void treeSearch_AfterSelect(object sender, TreeViewEventArgs e)
{
int nSel = e.Node.Index;
RefreshInterFace(nSel);
}
private void RefreshInterFace(int nSel)
{
if (m_nShowType == nSel)
{
return;
}
}
public void btnSearchClick()
{
SearchTreeView treeView = new SearchTreeView();
if (treeSearch.SelectedNode = )
这个if中该填什么条件才能表示是我选择的对象呢

{
UserSearch usersearch = new UserSearch();
if (usersearch.ShowDialog() == DialogResult.OK)
{
LoadUser(UserSearch.m_strSql);
}
}
else if(== "操作记录查询")
{
LogSearch logsearch = new LogSearch();
if (logsearch.ShowDialog() == DialogResult.OK)
{
LoadOperateLogReport(LogSearch.m_strSql);
}
}
}
展开
 我来答
桃李不言教书育人
推荐于2016-05-06 · TA获得超过1530个赞
知道小有建树答主
回答量:381
采纳率:0%
帮助的人:301万
展开全部
你的问题不太明确。给你个鼠标选中treeview节点的代码,参考一下吧。

//选中TreeView控件中的一个节点
private void treeView1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point clickPoint = new Point(e.X, e.Y);
TreeNode treeNode = treeView1.GetNodeAt(clickPoint);
if (treeNode != null)
{
//选中子节点
if (treeNode.Parent != null)
{
treeView1.SelectedNode = treeNode;
//这里写你想要对根节点进行的操作
}
else return;

}
}
if (e.Button == MouseButtons.Right)//可以改成左键响应
{

Point clickPoint = new Point(e.X, e.Y);
TreeNode treeNode = treeView1.GetNodeAt(clickPoint);
if (treeNode != null)
{
//选中根节点,右键菜单可用。
if (treeNode.Parent == null)
{
if (treeNode.GetNodeCount(true) > 0)
{
//这里写你想要对根节点进行的操作

}
}
else return;

}
}

}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式