| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 947 人关注过本帖
标题:c# treeview单击控件怎么消掉原来的内容
取消只看楼主 加入收藏
Donnie
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-10-19
结帖率:50%
收藏
 问题点数:0 回复次数:2 
c# treeview单击控件怎么消掉原来的内容
我在treeview控件上定义了两个radiobutton按钮一个为单位.一个为类型,现在当我单击单位后在单击类型,单位按钮的内容不刷新,而是把类型的内容叠加上去,点类型一样.要做的就是当我点单位就只出现单位的内容,点类型就只出类型的内容

最好是给代码,小弟才上,实在没有分给,对不住了,谢谢,助人为乐吗
搜索更多相关主题的帖子: 控件 单击 treeview 
2009-09-21 02:11
Donnie
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-10-19
收藏
得分:0 
这就是
public string tn1;


        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                TreeNode tn1 = treeView1.Nodes.Add("档案管理系统");
                string SQLstr = "SELECT DISTINCT ZZLBID,ZZLBName from ZZLBTable";// where ZZLBName = 1 ";//and sn in(" + all.Substring(0, all.Length - 1).ToString() + ")";
                SqlDataAdapter objAdapterNode = new SqlDataAdapter(SQLstr, My_con);
                DataSet My_DataSet = new DataSet();
                My_DataSet.Clear();
                objAdapterNode.Fill(My_DataSet, "temp");
                DataTable dt = My_DataSet.Tables["temp"];
                tn1.Nodes.Clear();

                //建立根节点,遍历。

                foreach (DataRow dr in dt.Rows)
                {
                    TreeNode Root = new TreeNode();
                    Root.Text = dr["ZZLBName"].ToString();
                    tn1.Nodes.Add(Root);
                    //TreeView1.Nodes.add(Root);//建立根节点


                    string str = "SELECT UnitID,ZZClass from ComeFile_Base ";//where UnitID = " + dr["ZZLBID"].ToString() + "' and ComeFile_Base in (" + ZZLBName.Substring(0, ZZLBName.Length - 1).ToString() + ")" + "order by ZZLBID,UnitID";
                    SqlDataAdapter objAdapter = new SqlDataAdapter(str, My_con);
                    DataSet dsNode = new DataSet();
                    dsNode.Clear();
                    objAdapter.Fill(dsNode, "tempNode");
                    DataTable dtNode = dsNode.Tables["tempNode"];

                    //建立子节点,遍历。

                    foreach (DataRow drNode in dtNode.Rows)
                    {
                        TreeNode Node = new TreeNode();
                        Node.Text = drNode["ZZClass"].ToString();
                        //Node.Target = "RightFrame";

                        string Path = drNode["UnitID"].ToString();
                        //int menusn = Convert.ToInt32(drNode["ZZClass"].ToString());
                        Node.Name = "Transfer.aspx" + "?ZZClass=" + Path;

                        Root.Nodes.Add(Node);//建立子节点
                    }
                }
            }
            catch (Exception edf)
            {
                MessageBox.Show(" 错误!('您没有可操作的菜单项!'); " + edf.Message);
            }


        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            
            try
            {
                TreeNode tn1 = treeView1.Nodes.Add("档案管理系统");
                string SQLstr = "SELECT DISTINCT ZZLBID,ZZLBName from ZZLBTable";// where ZZLBName = 1 ";//and sn in(" + all.Substring(0, all.Length - 1).ToString() + ")";
                SqlDataAdapter objAdapterNode = new SqlDataAdapter(SQLstr, My_con);
                DataSet My_DataSet = new DataSet();
                My_DataSet.Clear();
                objAdapterNode.Fill(My_DataSet, "temp");
                DataTable dt = My_DataSet.Tables["temp"];
                tn1.Nodes.Clear();

                //建立根节点,遍历。

                foreach (DataRow dr in dt.Rows)
                {
                    TreeNode Root = new TreeNode();
                    Root.Text = dr["ZZLBName"].ToString();
                    tn1.Nodes.Add(Root);
                    //TreeView1.Nodes.add(Root);//建立根节点


                    string str = "SELECT UnitID,UnitName from ComeFile_Base ";//where UnitID = " + dr["ZZLBID"].ToString() + "' and ComeFile_Base in (" + ZZLBName.Substring(0, ZZLBName.Length - 1).ToString() + ")" + "order by ZZLBID,UnitID";
                    SqlDataAdapter objAdapter = new SqlDataAdapter(str, My_con);
                    DataSet dsNode = new DataSet();
                    dsNode.Clear();
                    objAdapter.Fill(dsNode, "tempNode");
                    DataTable dtNode = dsNode.Tables["tempNode"];

                    //建立子节点,遍历。

                    foreach (DataRow drNode in dtNode.Rows)
                    {
                        TreeNode Node = new TreeNode();
                        Node.Text = drNode["UnitName"].ToString();
                        //Node.Target = "mainbottom";

                        string Path = drNode["UnitID"].ToString();
                        //int menusn = Convert.ToInt32(drNode["ZZClass"].ToString());
                        Node.Name = "Transfer.aspx" + "?UnitName=" + Path;

                        Root.Nodes.Add(Node);//建立子节点



                    }
                }
            }
               
            catch (Exception edf)
            {
                MessageBox.Show(" 错误!('您没有可操作的菜单项!'); " + edf.Message);
            }

        }
2009-09-21 09:42
Donnie
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-10-19
收藏
得分:0 
大侠们,那么还是不行啊
2009-09-22 13:57
快速回复:c# treeview单击控件怎么消掉原来的内容
数据加载中...
 
   



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

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