就象论坛左侧的样子,要可以动态添加的
我是个新手,哪位兄弟姐妹能帮帮我啊
有源码捧个源场
有网址捧个址场
有人气就顶下啊
感激不进
15 个解决方案
#1
up
#2
进来的兄弟
能指个路
告诉我去哪下也行啊
能指个路
告诉我去哪下也行啊
#3
动态添加还没做的到,顶你
#4
up
#5
参考一下
private void BuildTree(TreeNodeCollection nodes,DataSet ds,int node)
{
foreach(DaraRow dr in ds.Tables[0].Rows)
{
if(Convert.ToInt32(dr[0])==node)
{
TreeNode tn=new TreeNode();
tn.Text="";
tn.Tag="";
nodes.Add(tn);
BuildTree(nodes,ds,Convert.ToInt32(tn.Tag));
}
}
}
private void BuildTree(TreeNodeCollection nodes,DataSet ds,int node)
{
foreach(DaraRow dr in ds.Tables[0].Rows)
{
if(Convert.ToInt32(dr[0])==node)
{
TreeNode tn=new TreeNode();
tn.Text="";
tn.Tag="";
nodes.Add(tn);
BuildTree(nodes,ds,Convert.ToInt32(tn.Tag));
}
}
}
#6
#7
98%的情况下只需要用到2级就够了
#8
up
#9
http://singlepine.cnblogs.com/articles/367801.html
#10
1.在一个字符串中(1,2,2,3,3,4,5,5,7,6)如何得出不包含重复字符的(1,2,3,4,5,7,6)?
2.字符串中"12,32,15,2,3,56,15,2," 如何去掉尾部的","号,即得出(12,32,15,2,3,56,15,2)?
3.谁知道vs2005中自带的treeview控件如何设置让它不点加号展开接点,而让它点击接点图象展开接点
还有不让它显示加号和接点文字,只显示接点图象.
谢谢大家的帮助
小弟在这等候佳音
2.字符串中"12,32,15,2,3,56,15,2," 如何去掉尾部的","号,即得出(12,32,15,2,3,56,15,2)?
3.谁知道vs2005中自带的treeview控件如何设置让它不点加号展开接点,而让它点击接点图象展开接点
还有不让它显示加号和接点文字,只显示接点图象.
谢谢大家的帮助
小弟在这等候佳音
#11
我也想要这个效果
兄弟你要晓得答案麻烦通知我一声.谢谢
兄弟你要晓得答案麻烦通知我一声.谢谢
#12
ding
#13
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindTreeView("PageFrameSpace", GetTreeViewTable());
}
}
#region 递归绑定树形目录
#endregion
private DataTable GetTreeViewTable()
{
DataTable dtProduct = objDB.GetDataTable("basGetGroupData", null);
return dtProduct;
}
#region BindTreeView
//邦定根节点
public void BindTreeView(string TargetFrame, DataTable dt)
{
DataRow[] drs = dt.Select("ParentNo= " + 0);// 选出所有子节点
tvGroupData.Nodes.Clear(); // 清空树
foreach (DataRow r in drs)
{
string nodeid = r["GroupNo"].ToString();
string text = r["GroupName"].ToString();
string parentid = r["ParentNo"].ToString();
string url = "UserData.aspx?strgroupno=" + r["GroupNo"].ToString();
string framename = TargetFrame;
this.tvGroupData.Font.Name = "宋体";
this.tvGroupData.Font.Size = FontUnit.Parse("9");
TreeNode rootnode = new TreeNode();
rootnode.Text = text;
rootnode.Value = nodeid;
rootnode.NavigateUrl = url;
rootnode.Target = framename;
//rootnode.SelectAction = TreeNodeSelectAction.Expand;//和ASP.NET1.1中TREEVIEW的SelectExpands属性等效
rootnode.SelectAction = TreeNodeSelectAction.None;
rootnode.Expanded = true;
tvGroupData.Nodes.Add(rootnode);
int sonparentid = int.Parse(nodeid);// or =location
CreateNode(framename, sonparentid, rootnode, dt);
}
}
// }
//邦定任意节点
public void CreateNode(string TargetFrame, int parentno, TreeNode parentnode, DataTable dt)
{
DataRow[] drs = dt.Select("ParentNo= " + parentno);//选出所有子节点
// tvGroupData.ShowCheckBoxes = TreeNodeTypes.Parent;
foreach (DataRow r in drs)
{
string nodeid = r["GroupNo"].ToString();
string text = r["GroupName"].ToString();
string url = "UserData.aspx?strgroupno=" + r["GroupNo"].ToString();
string framename = TargetFrame;
TreeNode node = new TreeNode();
node.Text = text;
node.Value = nodeid;
node.NavigateUrl = url;
node.Target = TargetFrame;
//node.SelectAction = TreeNodeSelectAction.Expand; //和ASP.NET1.1中TREEVIEW的SelectExpands属性等效
node.Expanded = true;
int sonparentid = int.Parse(nodeid);// or =location
if (parentnode == null)
{
tvGroupData.Nodes.Clear();
parentnode = new TreeNode();
tvGroupData.Nodes.Add(parentnode);
}
parentnode.ChildNodes.Add(node);
CreateNode(framename, sonparentid, node, dt);
// }//endif
}//endforeach
}
#endregion
}
{
if (!Page.IsPostBack)
{
BindTreeView("PageFrameSpace", GetTreeViewTable());
}
}
#region 递归绑定树形目录
#endregion
private DataTable GetTreeViewTable()
{
DataTable dtProduct = objDB.GetDataTable("basGetGroupData", null);
return dtProduct;
}
#region BindTreeView
//邦定根节点
public void BindTreeView(string TargetFrame, DataTable dt)
{
DataRow[] drs = dt.Select("ParentNo= " + 0);// 选出所有子节点
tvGroupData.Nodes.Clear(); // 清空树
foreach (DataRow r in drs)
{
string nodeid = r["GroupNo"].ToString();
string text = r["GroupName"].ToString();
string parentid = r["ParentNo"].ToString();
string url = "UserData.aspx?strgroupno=" + r["GroupNo"].ToString();
string framename = TargetFrame;
this.tvGroupData.Font.Name = "宋体";
this.tvGroupData.Font.Size = FontUnit.Parse("9");
TreeNode rootnode = new TreeNode();
rootnode.Text = text;
rootnode.Value = nodeid;
rootnode.NavigateUrl = url;
rootnode.Target = framename;
//rootnode.SelectAction = TreeNodeSelectAction.Expand;//和ASP.NET1.1中TREEVIEW的SelectExpands属性等效
rootnode.SelectAction = TreeNodeSelectAction.None;
rootnode.Expanded = true;
tvGroupData.Nodes.Add(rootnode);
int sonparentid = int.Parse(nodeid);// or =location
CreateNode(framename, sonparentid, rootnode, dt);
}
}
// }
//邦定任意节点
public void CreateNode(string TargetFrame, int parentno, TreeNode parentnode, DataTable dt)
{
DataRow[] drs = dt.Select("ParentNo= " + parentno);//选出所有子节点
// tvGroupData.ShowCheckBoxes = TreeNodeTypes.Parent;
foreach (DataRow r in drs)
{
string nodeid = r["GroupNo"].ToString();
string text = r["GroupName"].ToString();
string url = "UserData.aspx?strgroupno=" + r["GroupNo"].ToString();
string framename = TargetFrame;
TreeNode node = new TreeNode();
node.Text = text;
node.Value = nodeid;
node.NavigateUrl = url;
node.Target = TargetFrame;
//node.SelectAction = TreeNodeSelectAction.Expand; //和ASP.NET1.1中TREEVIEW的SelectExpands属性等效
node.Expanded = true;
int sonparentid = int.Parse(nodeid);// or =location
if (parentnode == null)
{
tvGroupData.Nodes.Clear();
parentnode = new TreeNode();
tvGroupData.Nodes.Add(parentnode);
}
parentnode.ChildNodes.Add(node);
CreateNode(framename, sonparentid, node, dt);
// }//endif
}//endforeach
}
#endregion
}
#14
大概说下,关键是数据库,里面多加2个字段,一个是本接点ID,一个是他的上一级接点ID,如果是跟接点,上级ID就是0。比如:
NOID UPNOID
001 000
002 001
003 001
这样就可以实现动态加载了
NOID UPNOID
001 000
002 001
003 001
这样就可以实现动态加载了
#15
同意楼上的...
#1
up
#2
进来的兄弟
能指个路
告诉我去哪下也行啊
能指个路
告诉我去哪下也行啊
#3
动态添加还没做的到,顶你
#4
up
#5
参考一下
private void BuildTree(TreeNodeCollection nodes,DataSet ds,int node)
{
foreach(DaraRow dr in ds.Tables[0].Rows)
{
if(Convert.ToInt32(dr[0])==node)
{
TreeNode tn=new TreeNode();
tn.Text="";
tn.Tag="";
nodes.Add(tn);
BuildTree(nodes,ds,Convert.ToInt32(tn.Tag));
}
}
}
private void BuildTree(TreeNodeCollection nodes,DataSet ds,int node)
{
foreach(DaraRow dr in ds.Tables[0].Rows)
{
if(Convert.ToInt32(dr[0])==node)
{
TreeNode tn=new TreeNode();
tn.Text="";
tn.Tag="";
nodes.Add(tn);
BuildTree(nodes,ds,Convert.ToInt32(tn.Tag));
}
}
}
#6
#7
98%的情况下只需要用到2级就够了
#8
up
#9
http://singlepine.cnblogs.com/articles/367801.html
#10
1.在一个字符串中(1,2,2,3,3,4,5,5,7,6)如何得出不包含重复字符的(1,2,3,4,5,7,6)?
2.字符串中"12,32,15,2,3,56,15,2," 如何去掉尾部的","号,即得出(12,32,15,2,3,56,15,2)?
3.谁知道vs2005中自带的treeview控件如何设置让它不点加号展开接点,而让它点击接点图象展开接点
还有不让它显示加号和接点文字,只显示接点图象.
谢谢大家的帮助
小弟在这等候佳音
2.字符串中"12,32,15,2,3,56,15,2," 如何去掉尾部的","号,即得出(12,32,15,2,3,56,15,2)?
3.谁知道vs2005中自带的treeview控件如何设置让它不点加号展开接点,而让它点击接点图象展开接点
还有不让它显示加号和接点文字,只显示接点图象.
谢谢大家的帮助
小弟在这等候佳音
#11
我也想要这个效果
兄弟你要晓得答案麻烦通知我一声.谢谢
兄弟你要晓得答案麻烦通知我一声.谢谢
#12
ding
#13
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindTreeView("PageFrameSpace", GetTreeViewTable());
}
}
#region 递归绑定树形目录
#endregion
private DataTable GetTreeViewTable()
{
DataTable dtProduct = objDB.GetDataTable("basGetGroupData", null);
return dtProduct;
}
#region BindTreeView
//邦定根节点
public void BindTreeView(string TargetFrame, DataTable dt)
{
DataRow[] drs = dt.Select("ParentNo= " + 0);// 选出所有子节点
tvGroupData.Nodes.Clear(); // 清空树
foreach (DataRow r in drs)
{
string nodeid = r["GroupNo"].ToString();
string text = r["GroupName"].ToString();
string parentid = r["ParentNo"].ToString();
string url = "UserData.aspx?strgroupno=" + r["GroupNo"].ToString();
string framename = TargetFrame;
this.tvGroupData.Font.Name = "宋体";
this.tvGroupData.Font.Size = FontUnit.Parse("9");
TreeNode rootnode = new TreeNode();
rootnode.Text = text;
rootnode.Value = nodeid;
rootnode.NavigateUrl = url;
rootnode.Target = framename;
//rootnode.SelectAction = TreeNodeSelectAction.Expand;//和ASP.NET1.1中TREEVIEW的SelectExpands属性等效
rootnode.SelectAction = TreeNodeSelectAction.None;
rootnode.Expanded = true;
tvGroupData.Nodes.Add(rootnode);
int sonparentid = int.Parse(nodeid);// or =location
CreateNode(framename, sonparentid, rootnode, dt);
}
}
// }
//邦定任意节点
public void CreateNode(string TargetFrame, int parentno, TreeNode parentnode, DataTable dt)
{
DataRow[] drs = dt.Select("ParentNo= " + parentno);//选出所有子节点
// tvGroupData.ShowCheckBoxes = TreeNodeTypes.Parent;
foreach (DataRow r in drs)
{
string nodeid = r["GroupNo"].ToString();
string text = r["GroupName"].ToString();
string url = "UserData.aspx?strgroupno=" + r["GroupNo"].ToString();
string framename = TargetFrame;
TreeNode node = new TreeNode();
node.Text = text;
node.Value = nodeid;
node.NavigateUrl = url;
node.Target = TargetFrame;
//node.SelectAction = TreeNodeSelectAction.Expand; //和ASP.NET1.1中TREEVIEW的SelectExpands属性等效
node.Expanded = true;
int sonparentid = int.Parse(nodeid);// or =location
if (parentnode == null)
{
tvGroupData.Nodes.Clear();
parentnode = new TreeNode();
tvGroupData.Nodes.Add(parentnode);
}
parentnode.ChildNodes.Add(node);
CreateNode(framename, sonparentid, node, dt);
// }//endif
}//endforeach
}
#endregion
}
{
if (!Page.IsPostBack)
{
BindTreeView("PageFrameSpace", GetTreeViewTable());
}
}
#region 递归绑定树形目录
#endregion
private DataTable GetTreeViewTable()
{
DataTable dtProduct = objDB.GetDataTable("basGetGroupData", null);
return dtProduct;
}
#region BindTreeView
//邦定根节点
public void BindTreeView(string TargetFrame, DataTable dt)
{
DataRow[] drs = dt.Select("ParentNo= " + 0);// 选出所有子节点
tvGroupData.Nodes.Clear(); // 清空树
foreach (DataRow r in drs)
{
string nodeid = r["GroupNo"].ToString();
string text = r["GroupName"].ToString();
string parentid = r["ParentNo"].ToString();
string url = "UserData.aspx?strgroupno=" + r["GroupNo"].ToString();
string framename = TargetFrame;
this.tvGroupData.Font.Name = "宋体";
this.tvGroupData.Font.Size = FontUnit.Parse("9");
TreeNode rootnode = new TreeNode();
rootnode.Text = text;
rootnode.Value = nodeid;
rootnode.NavigateUrl = url;
rootnode.Target = framename;
//rootnode.SelectAction = TreeNodeSelectAction.Expand;//和ASP.NET1.1中TREEVIEW的SelectExpands属性等效
rootnode.SelectAction = TreeNodeSelectAction.None;
rootnode.Expanded = true;
tvGroupData.Nodes.Add(rootnode);
int sonparentid = int.Parse(nodeid);// or =location
CreateNode(framename, sonparentid, rootnode, dt);
}
}
// }
//邦定任意节点
public void CreateNode(string TargetFrame, int parentno, TreeNode parentnode, DataTable dt)
{
DataRow[] drs = dt.Select("ParentNo= " + parentno);//选出所有子节点
// tvGroupData.ShowCheckBoxes = TreeNodeTypes.Parent;
foreach (DataRow r in drs)
{
string nodeid = r["GroupNo"].ToString();
string text = r["GroupName"].ToString();
string url = "UserData.aspx?strgroupno=" + r["GroupNo"].ToString();
string framename = TargetFrame;
TreeNode node = new TreeNode();
node.Text = text;
node.Value = nodeid;
node.NavigateUrl = url;
node.Target = TargetFrame;
//node.SelectAction = TreeNodeSelectAction.Expand; //和ASP.NET1.1中TREEVIEW的SelectExpands属性等效
node.Expanded = true;
int sonparentid = int.Parse(nodeid);// or =location
if (parentnode == null)
{
tvGroupData.Nodes.Clear();
parentnode = new TreeNode();
tvGroupData.Nodes.Add(parentnode);
}
parentnode.ChildNodes.Add(node);
CreateNode(framename, sonparentid, node, dt);
// }//endif
}//endforeach
}
#endregion
}
#14
大概说下,关键是数据库,里面多加2个字段,一个是本接点ID,一个是他的上一级接点ID,如果是跟接点,上级ID就是0。比如:
NOID UPNOID
001 000
002 001
003 001
这样就可以实现动态加载了
NOID UPNOID
001 000
002 001
003 001
这样就可以实现动态加载了
#15
同意楼上的...