关于TreeView生成时的IndexOf值获取、传输的问题 本帖最后由 soundofsea 于 2009-07-12 22:10:50 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public static void AddNodes(TreeView tv, DataTable dt, string text, string value, string url, string rootselect, string rootselectvalue, int rootindex, string childselect, string childselectvalue, string ordervalue, string ovalue) { DataRow[] root = dt.Select(rootselect + "=" + rootselectvalue, ordervalue + " " + ovalue); for (int i = 0; i < root.Length; i++) { TreeNode tn = new TreeNode(); tn.Text = root[i][text].ToString(); tn.SelectAction = TreeNodeSelectAction.None; tn.Value = root[i][value].ToString(); tv.Nodes.AddAt(rootindex, tn); if (i != root.Length - 1) { tn.Expanded = false; } addchilid(dt, text, value, url, childselect, childselectvalue, tn, root[i], ordervalue, ovalue); } } private static void addchilid(DataTable dt, string text, string value, string url, string childselect, string childselectvalue, TreeNode ftn, DataRow fdr, string ordervalue, string ovalue) { DataRow[] child = dt.Select(childselect + "=" + fdr[childselectvalue].ToString(), ordervalue); for (int j = 0; j < child.Length; j++) { TreeNode ctn = new TreeNode(); ctn.Text = child[j][text].ToString(); ctn.NavigateUrl = child[j][url].ToString(); ctn.Value = child[j][value].ToString(); ftn.ChildNodes.Add(ctn); addchilid(dt, text, value, url, childselect, childselectvalue, ctn, child[j], ordervalue, ovalue); } } TreeNode TN = new TreeNode(); TN.Text = DS.Tables[0].Rows[i][1].ToString(); TN.Value = DS.Tables[0].Rows[i][0].ToString(); TreeView1.Nodes.Add(TN);生成节点后,我如何才能获取本节点的 IndexOf 的索引值?我的子节点在添加时需要Nodes[父节点值]TreeView1.Nodes[0].ChildNodes.Add(TN); 关于datatable 读取excel的问题 关于控件在工具箱显示的问题,帮帮忙 SQL问题 寻找个小软件 有谁认识? dropdownlist绑定 关于程序启动的时候如何加载类和如何在程序中用的问题? 水晶报表部署失败,可能和com有关 高分请教关于C#中操作符重载的问题! 请问如何让程序通过局域网内的另一个公网ip访问外网 Ueditor 从word中复制内容带多张图片。 c#怎么用有参的构造方法调用无参的构造方法? CS0149: 应输入方法名称,Asp.Net C#错误提示该怎么改?
string value, string url, string rootselect, string rootselectvalue,
int rootindex, string childselect, string childselectvalue, string ordervalue, string ovalue)
{ DataRow[] root = dt.Select(rootselect + "=" + rootselectvalue, ordervalue + " " + ovalue);
for (int i = 0; i < root.Length; i++)
{
TreeNode tn = new TreeNode();
tn.Text = root[i][text].ToString();
tn.SelectAction = TreeNodeSelectAction.None;
tn.Value = root[i][value].ToString();
tv.Nodes.AddAt(rootindex, tn);
if (i != root.Length - 1)
{
tn.Expanded = false;
} addchilid(dt, text, value, url, childselect, childselectvalue, tn, root[i], ordervalue, ovalue);
}
}
private static void addchilid(DataTable dt, string text,
string value, string url, string childselect,
string childselectvalue, TreeNode ftn, DataRow fdr, string ordervalue, string ovalue)
{
DataRow[] child = dt.Select(childselect + "=" + fdr[childselectvalue].ToString(), ordervalue);
for (int j = 0; j < child.Length; j++)
{
TreeNode ctn = new TreeNode();
ctn.Text = child[j][text].ToString();
ctn.NavigateUrl = child[j][url].ToString();
ctn.Value = child[j][value].ToString();
ftn.ChildNodes.Add(ctn); addchilid(dt, text, value, url, childselect, childselectvalue, ctn, child[j], ordervalue, ovalue);
}
}
TreeNode TN = new TreeNode();
TN.Text = DS.Tables[0].Rows[i][1].ToString();
TN.Value = DS.Tables[0].Rows[i][0].ToString();
TreeView1.Nodes.Add(TN);
生成节点后,我如何才能获取本节点的 IndexOf 的索引值?
我的子节点在添加时需要Nodes[父节点值]TreeView1.Nodes[0].ChildNodes.Add(TN);