最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

C#树视图和列表视图

SEO心得admin56浏览0评论
本文介绍了C#树视图和列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { //SqlConnection con = new SqlConnection("Data Source=AKS14;Initial Catalog=TreeviewSampleDb;Integrated Security=SSPI"); //DataSet dataset = new DataSet(); //con.Open(); //dataset.Clear(); //string strcon = "select * from tblHead"; //SqlDataAdapter da = new SqlDataAdapter(strcon, con); //da.Fill(dataset); // write this code inside your treeview NodeMouseCLick event TreeNode tn = e.Node; //create a datatable with two columns DataTable aTable = new DataTable(); aTable.Columns.Add("Headid", typeof(string)); aTable.Columns.Add("HeadName", typeof(string)); //in this for each loop we will traverse through the clicked tree node // and get all child nodes name and tag(value) and keep it in datarow // of our datatable . foreach (TreeNode t1 in tn.Nodes) { DataRow dr; dr = aTable.NewRow(); dr[0] = t1.Text; dr[1] = t1.Tag.ToString(); } //finally we will make datatabe as the source of listview listView1.datasource = aTable;

在Windows c#中单击左侧的树视图和右侧的列表视图.在树视图中单击父节点"后,子级将以其ID在列表视图中显示.怎么办??? listview1.datasource在Windows中不起作用. articleid = 16> www.progtalk/viewarticle.aspx?articleid=16 [ ^ ]

private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { //SqlConnection con = new SqlConnection("Data Source=AKS14;Initial Catalog=TreeviewSampleDb;Integrated Security=SSPI"); //DataSet dataset = new DataSet(); //con.Open(); //dataset.Clear(); //string strcon = "select * from tblHead"; //SqlDataAdapter da = new SqlDataAdapter(strcon, con); //da.Fill(dataset); // write this code inside your treeview NodeMouseCLick event TreeNode tn = e.Node; //create a datatable with two columns DataTable aTable = new DataTable(); aTable.Columns.Add("Headid", typeof(string)); aTable.Columns.Add("HeadName", typeof(string)); //in this for each loop we will traverse through the clicked tree node // and get all child nodes name and tag(value) and keep it in datarow // of our datatable . foreach (TreeNode t1 in tn.Nodes) { DataRow dr; dr = aTable.NewRow(); dr[0] = t1.Text; dr[1] = t1.Tag.ToString(); } //finally we will make datatabe as the source of listview listView1.datasource = aTable;

leftside treeview and right side listview in windows c#.after click parents node in treeview the child show in listview with his ids. how to do??? listview1.datasource is not working in windows.

解决方案

Nice reference available at: www.progtalk/viewarticle.aspx?articleid=16[^]

发布评论

评论列表(0)

  1. 暂无评论