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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
Spread Privacy
Spread Privacy
I
InfoQ
V
V2EX
S
Schneier on Security
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Attack and Defense Labs
Attack and Defense Labs
云风的 BLOG
云风的 BLOG
The Hacker News
The Hacker News
S
SegmentFault 最新的问题
C
Cybersecurity and Infrastructure Security Agency CISA
NISL@THU
NISL@THU
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
Latest news
Latest news
S
Secure Thoughts
Project Zero
Project Zero
MongoDB | Blog
MongoDB | Blog
I
Intezer
Security Latest
Security Latest
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
N
Netflix TechBlog - Medium
V2EX - 技术
V2EX - 技术
量子位
T
Threatpost
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog
T
Tor Project blog
A
Arctic Wolf
Microsoft Security Blog
Microsoft Security Blog
T
The Exploit Database - CXSecurity.com
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
博客园 - Franky
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
L
LINUX DO - 热门话题

博客园 - Asidy

[转]禁止在 .NET Framework 中执行用户代码。启用 "clr enabled" 配置选项 - Asidy [转]SQL Server 2005备份集中的数据库备份与现有的数据库不同的解决方法 asp.net中向数据库中插入数据时如何获得当前插入行的主键? css中visibility与display的区别 一个比较纯洁的DIV+CSS下拉菜单 基于.NET平台的Windows编程实战系列课程导航及源码下载 一个用JS写的IP/时间/日期/email的验证函数 [转]同时安装MSSQL2000与MSSQL2005时所遇到的问题及解决方法小记 一个老师的自责、道歉与思考 基于.NET平台的Windows编程实战(九)— 安装与部署 基于.NET平台的Windows编程实战(八)— 数据库管理及其他辅助功能的实现 基于.NET平台的Windows编程实战(七)—— 问卷统计功能的实现 基于.NET平台的Windows编程实战(六)—— 题目管理功能的实现 让别人说话 基于.NET平台的Windows编程实战(五)—— 问卷管理功能的实现 [翻译]在Windows窗体中如何使用透明图片和标签 基于.NET平台的Windows编程实战(四)—— 数据库操作类的编写 基于.NET平台的Windows编程实战(三)—— 项目的创建及主界面的设计 FileStream类/StreamWriter类/StreamReader的使用
LINQ编程实战之TreeView动态绑定数据
Asidy · 2009-06-18 · via 博客园 - Asidy

之前写了个WPF(Winform)中动态创建TreeView 的随笔,现在再在此文的基础上整一个LINQ的吧,感觉用LINQ简单多了,看来微软是越来越有意思了,呵呵,下面开始吧……

首先,先来重新创建一个数据库表,这里的数据库表与之前所创建的表有些不同,大家可以自己对比一下。

Code

创建好数据库表后,就是打开数据库连接了,具体的打开方法在这里就不哆嗦了,可参考一下WPF(Winform)中动态创建TreeView 中第二步。

然后,一起来看看其数据的绑定方法吧: 

Code

最后,在需要的地方直接调用BindMenuData()就可以了。

当然你也可以重写一个带TreeView参数的方法,如:BindMenuData(TreeView MenuTView),来动态创建TreeView。

希望能给大家带来一点帮助……