惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
D
Docker
Blog — PlanetScale
Blog — PlanetScale
罗磊的独立博客
美团技术团队
V
V2EX
Last Week in AI
Last Week in AI
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
Microsoft Security Blog
Microsoft Security Blog
Microsoft Azure Blog
Microsoft Azure Blog
人人都是产品经理
人人都是产品经理
M
MIT News - Artificial intelligence
P
Proofpoint News Feed
B
Blog RSS Feed
博客园_首页
B
Blog
博客园 - 叶小钗
I
InfoQ
WordPress大学
WordPress大学
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
A
About on SuperTechFans
The GitHub Blog
The GitHub Blog
The Register - Security
The Register - Security
MyScale Blog
MyScale Blog
云风的 BLOG
云风的 BLOG
博客园 - 司徒正美
Latest news
Latest news
W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
C
CXSECURITY Database RSS Feed - CXSecurity.com
Recent Commits to openclaw:main
Recent Commits to openclaw:main
N
News and Events Feed by Topic
S
Secure Thoughts
The Hacker News
The Hacker News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News

博客园 - somesongs

好多年没回到这个园子 有趣的多媒体 发布简短计划,备忘 Intelligencia.UrlRewriter, 解决404找不到文件的问题 forms验证如此简单 在一个页面中调用另一个页面定义的函数 .net中,数据提交完毕后,刷新绑定控件,清空输入框的好办法,就是在时间函数的最后加入Response.Redirect(Request.FilePath); [转] Trace跟踪输出进行调试 Flash的全屏播放(转) flash中实现拖拽 .net从后台返回js的提示框 编写xmlhelper类【翻译】 [转]C#网络编程概述 【转】C#网络编程初探 只需一行代码实现增删查改,微软已经让我们很简单。谈AccessDataSource的使用。 document.body.clientHeight与document.documentElement.clientHeight 动态将Js代码写入到Head标签中 Asp.net中删除前的提示信息 location和history的详细设置
Treeview中,递归生成从当前选中节点到根节点的全路径
somesongs · 2009-02-02 · via 博客园 - somesongs

Treeview常用来导航,有时候需要有一个横向的路径式的导航,我们可以直接从treeview动态生成。这个内容让我对递归有了一些亲近的味道,以前总是怕怕。

 1         protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
 2         {
 3 
 4             TreeNode theNode = TreeView1.SelectedNode;
 5 
 6             Label1.Text = getTextPath(theNode);
 7         }
 8 
 9         //生成从当前节点到根节点的路径
10         public string getTextPath(TreeNode theNode)
11         {
12             string result = theNode.Text;
13 
14             if (theNode.Parent != null)
15             {
16                 result = theNode.Parent.Text + " >> " + result;
17 
18                 getTextPath(theNode.Parent);
19             }
20 
21             return result;
22         }

一个多简单的递归!结果如下图: