日期:2014-05-18  浏览次数:21100 次

C#的treeview节点选择
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);
  }
  }
  }

------解决方案--------------------
没看懂楼主表达什么意思呢?
------解决方案--------------------
不太明白楼主的意思,不知道写的对不对:
C# code

if (treeSearch.SelectedNode!=null)

------解决方案--------------------
C# code

   //删除
    protected void ButtonDel_Click(object sender, EventArgs e)
    {
        if (TreeView_App.SelectedNode != null)
        {
             string aa = TreeView_App.SelectedNode.Value;
         }
    }