| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 6142 人关注过本帖
标题:或取treeview树型的节点单击事件
只看楼主 加入收藏
Donnie
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-10-19
结帖率:50%
收藏
 问题点数:0 回复次数:5 
或取treeview树型的节点单击事件
在左边的treeview树型的节点中,我任一节点,或取单击事件和在右边窗口中显示数据.数据从server中读取

节点是从数据库中动态读取.
搜索更多相关主题的帖子: 单击 节点 treeview 
2009-09-17 01:53
jedypjd
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:9
帖 子:1096
专家分:4969
注 册:2009-7-27
收藏
得分:0 
我正在搞这个呢,可以交流一下,178169475

天涯无岁月,歧路有风尘,百年浑似醉,是非一片云
2009-09-17 08:30
飙马
Rank: 5Rank: 5
来 自:马里亚纳
等 级:贵宾
威 望:15
帖 子:779
专家分:280
注 册:2007-3-28
收藏
得分:0 
先AfterCheck,再递归遍历。

IT精英如同彩票:平凡的人像5块也中不到一样普遍,努力一点你中了5元保了个本。奖金越高,机率也就越小,付出的也越多,盖茨如同500万一样稀有。虽然每天忙碌而平凡,但我努力成为精英,做梦中了500万。
2009-09-17 14:08
YOUDIANSHUI
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:39
专家分:108
注 册:2008-12-10
收藏
得分:0 
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using
 
namespace DirectoryExplorerCS
{
    public partial class ExplorerForm : Form
    {
        public ExplorerForm()
        {
            InitializeComponent();
        }
 
        private void AddChildren(TreeNode parentNode)
        {
            DirectoryInfo dirInfo = (DirectoryInfo)parentNode.Tag;
 
            try
            {
                foreach (DirectoryInfo dir in dirInfo.GetDirectories())
                {
                    TreeNode node = new TreeNode();
                    node.Text = dir.Name;
                    node.Tag = dir;
                    parentNode.Nodes.Add(node);
                }
            }
            catch (Exception e)
            {
                //MessageBox.Show(e.ToString());
            }
        }
 
        private void ExplorerForm_Load(object sender, EventArgs e)
        {
            TreeNode rootNode = new TreeNode();
            rootNode.Text = "C:";
            rootNode.Tag = new DirectoryInfo("C:\\");
            directoryTree.Nodes.Add(rootNode);
            AddChildren(rootNode);
        }
 
        private void directoryTree_AfterExpand(object sender, TreeViewEventArgs e)
        {
            foreach (TreeNode node in e.Node.Nodes)
            {
                if (node.Nodes.Count == 0)
                {
                    AddChildren(node);
                }
            }
        }
 
        
        private void directoryTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            DirectoryInfo dirInfo = (DirectoryInfo)e.Node.Tag;
            detailListView.Items.Clear();
            try
            {
                foreach (DirectoryInfo childDir in dirInfo.GetDirectories())
                {
                    //largeImageList.Images.Add(Icon.ExtractAssociatedIcon(childDir.FullName));
                    ListViewItem item = new ListViewItem();
                    item.ImageIndex = 0;
                    item.Text = childDir.Name;
                    item.SubItems.Add("");  
                    item.SubItems.Add("文件夹");
                    item.SubItems.Add(childDir.LastWriteTime.ToString());
                    detailListView.Items.Add(item);
                }
            }
            catch
            {
            }
        }
 
           }
        }
    }
}
2009-09-17 15:05
Mo诫
Rank: 4
等 级:业余侠客
帖 子:80
专家分:223
注 册:2009-7-29
收藏
得分:0 
public void treeviewView()
        {
            //显示父节点
            string sql = "select * from Company_Infor";
            SqlDataAdapter adapter = new SqlDataAdapter(sql, conn.Link());
            DataSet resultDS = new DataSet();
            adapter.Fill(resultDS, "Company_Infor");
            foreach (DataRow row in resultDS.Tables["Company_Infor"].Rows)
            {
                sql = "select top 1 * from Company_Infor";
                adapter = new SqlDataAdapter(sql, conn.Link());
                adapter.Fill(resultDS, row["Company_Name"].ToString());
                TreeNode tn = new TreeNode();
                tn.Name = row["Company_ID"].ToString();
                tn.Text = row["Company_Name"].ToString();
                string companyid = row["Company_ID"].ToString();
 
                treeView1.Nodes.Add(tn);
 
 
                //部门子节点
                string sectionsql = "select * from Section_Infor";
                SqlDataAdapter sectionadapter = new SqlDataAdapter(sectionsql, conn.Link());
                DataSet sectionDS = new DataSet();
                sectionadapter.Fill(sectionDS, "Section_Infor");
 
                foreach (DataRow sectionrow in sectionDS.Tables["Section_Infor"].Rows)
                {
 
                    sectionsql = "select top 1 * from Section_Infor";
                    sectionadapter = new SqlDataAdapter(sectionsql, conn.Link());
                    sectionadapter.Fill(sectionDS, sectionrow["Section_Name"].ToString());
                    TreeNode sectn = new TreeNode();
                    sectn.Name = sectionrow["Section_ID"].ToString();
                    sectn.Text = sectionrow["Section_Name"].ToString();
 
                    string FKcompanyid = sectionrow["Company_ID"].ToString();
                    if (FKcompanyid == companyid)
                        tn.Nodes.Add(sectn);
                }
 
            }
            
  
        }
这个也许你有用  是加载的数据库中的字段  但代码你还要封装哈
2009-09-17 16:06
Mo诫
Rank: 4
等 级:业余侠客
帖 子:80
专家分:223
注 册:2009-7-29
收藏
得分:0 
说句。。4楼的谢了
2009-09-17 16:09
快速回复:或取treeview树型的节点单击事件
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016786 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved