treeviews的问题,大侠进来吧 http://blog.csdn.net/xietangz/articles/243306.aspx 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 数据库id 自动增长IDpid 父IDdept 深度context 接点内容 /// <summary> /// 连接数据库添加节点 /// </summary> private void AddTree() { SqlConnection con = new SqlConnection("server=.;database=fairyland;integrated security=SSPI"); SqlCommand cmd = con.CreateCommand(); string sql = "select * from addTree"; try { con.Open(); cmd.CommandText = sql; SqlDataAdapter adapter = new SqlDataAdapter(cmd); adapter.Fill(ds); GetTree(0, (TreeNode)null); } catch (SqlException ex) { throw ex; } finally { con.Close(); } } /// <summary> /// 循环添加节点 /// </summary> /// <param name="parentId"></param> /// <param name="tnode"></param> private void GetTree(int parentId, TreeNode tnode) { DataView tv = new DataView(ds.Tables[0]); tv.RowFilter = "ParentID=" + parentId; foreach (DataRowView Row in tv) { if (tnode == null) { TreeNode Node = treeView1.Nodes.Add("("+Row["ID"].ToString()+")"+Row["ConText"].ToString()); GetTree(Int32.Parse(Row["ID"].ToString()), Node); } else { TreeNode Node = tnode.Nodes.Add("(" + Row["ID"].ToString() + ")" + Row["ConText"].ToString()); GetTree(Int32.Parse(Row["ID"].ToString()), Node); } } } "ParentID= " + parentId,是什么意思,不明白,分别代表什么,请详解 表达式用于筛选dataview的数据 winform如何更改鼠标Cursor 不能发贴 .net进行编译时遇到的问题 判断输入焦点问题 有什么语言能操作excel中的菜单啊,比如新建一个菜单,并且能操作这个菜单,c#行吗,能不能给个例子 关于byte[]的转换 在DataGrid里面列的操作。 XML问题 怎样在上传的图片的时候打上logo 一个标准的xml有什么方法可以写入sql数据 C#中的datagridview控件,什么属性能够去掉"最前面的一列", 为什么绑定后却一条记录都显示不出来?
id 自动增长ID
pid 父ID
dept 深度
context 接点内容 /// <summary>
/// 连接数据库添加节点
/// </summary>
private void AddTree()
{
SqlConnection con = new SqlConnection("server=.;database=fairyland;integrated security=SSPI");
SqlCommand cmd = con.CreateCommand();
string sql = "select * from addTree";
try
{
con.Open();
cmd.CommandText = sql;
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds);
GetTree(0, (TreeNode)null);
}
catch (SqlException ex)
{
throw ex;
}
finally
{
con.Close();
}
} /// <summary>
/// 循环添加节点
/// </summary>
/// <param name="parentId"></param>
/// <param name="tnode"></param>
private void GetTree(int parentId, TreeNode tnode)
{
DataView tv = new DataView(ds.Tables[0]);
tv.RowFilter = "ParentID=" + parentId;
foreach (DataRowView Row in tv)
{
if (tnode == null)
{
TreeNode Node = treeView1.Nodes.Add("("+Row["ID"].ToString()+")"+Row["ConText"].ToString());
GetTree(Int32.Parse(Row["ID"].ToString()), Node);
}
else
{
TreeNode Node = tnode.Nodes.Add("(" + Row["ID"].ToString() + ")" + Row["ConText"].ToString());
GetTree(Int32.Parse(Row["ID"].ToString()), Node);
}
}
}
用于筛选dataview的数据