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

推荐订阅源

N
News and Events Feed by Topic
S
Security @ Cisco Blogs
S
Secure Thoughts
Attack and Defense Labs
Attack and Defense Labs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
Recent Commits to openclaw:main
Recent Commits to openclaw:main
H
Hacker News: Front Page
博客园 - 叶小钗
H
Heimdal Security Blog
Microsoft Security Blog
Microsoft Security Blog
Forbes - Security
Forbes - Security
AI
AI
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
罗磊的独立博客
Application and Cybersecurity Blog
Application and Cybersecurity Blog
爱范儿
爱范儿
GbyAI
GbyAI
The Last Watchdog
The Last Watchdog
TaoSecurity Blog
TaoSecurity Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
D
DataBreaches.Net
Recent Announcements
Recent Announcements
Schneier on Security
Schneier on Security
C
Cisco Blogs
美团技术团队
D
Docker
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
月光博客
月光博客
雷峰网
雷峰网
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
H
Hackread – Cybersecurity News, Data Breaches, AI and More
A
Arctic Wolf
B
Blog RSS Feed
Cisco Talos Blog
Cisco Talos Blog
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
V2EX - 技术
V2EX - 技术
Y
Y Combinator Blog
N
News and Events Feed by Topic
www.infosecurity-magazine.com
www.infosecurity-magazine.com
W
WeLiveSecurity
Security Archives - TechRepublic
Security Archives - TechRepublic
G
GRAHAM CLULEY
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
The Hacker News
The Hacker News

博客园 - 秋枫

使用BizTalk Server常见问题处理 BizTalk Server中简单xml架构使用举例 CodeProject.com上微软BizTalk平台技术文章集锦 BizTalk Server 2006中使用MQSeries适配器问题处理 基于.Net平台应用程序唯一运行实例实现 使用BizTalk Server的Sql适配器出现“新事务不能登记到指定的事务处理器中”异常的处理 谈基于.net平台windows开发中的模式窗体 Visual studio 2005下xml的xsl转换调试 小提国内一些提供RSS服务的网站生成Rss文件问题 Visual studio .net 的“隐蔽性”和容易“忽略”的功能 使用sqlcmd(osql) 实用工具列出本地网内的Sql Server 服务器 《敏捷注册表》1.0使用说明书 《敏捷注册表》1.0概述 使用从BindingManagerBase.PositionChanged 事件的注意点 使用Microsoft SQL Server 2000的XML查询 asp.net中显示DataGrid控件列序号的几种方法 使用.net framewrok 1.1版注册表API的局限和解决 使用SaveFileDialog需要注意的情况 使用.net framework中常用类在2.0版中的新功能
使用.net framewrok 1.1版System.Windows.Forms.TreeView的一个问题
秋枫 · 2005-10-08 · via 博客园 - 秋枫

上个星期在使用TreeView的时候发现一个问题。假设TreeView中包含了多个根节点和子节点。如下图:

当在实例构造函数中或第一次使用他之前注册了TreeView.AfterSelect 事件,

this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);

下面为事件处理程序用来计算事件程序运行次数。

private int i = 0;

private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)

{

       i++;

       this.label1.Text = i.ToString();

}

(1).当第一次点击[节点1]时,i= 1;这个没有问题;如果第一次点击其他节点,比如[节点2]或[节点1.1],那i = 2,也就是选中一次节点产生了两个AfterSelect事件,对代码进行单步调试,发现第一次事件处理程序中的e.Node.Text值为”节点1”,也就是说第一次AfterSelect事件是由[节点1]产生(这里并没有点击该节点),而第二次的事件才是所想要的事件。

(2).针对这一点,笔者试着第一次点击节点前面的展开/折叠图标(+/-),无论点击的是不是第一个根节点,都会执行相当于选中了第一个根节点的事件。第一次调用this.treeView1.Select();函数时也会如此。

对于(1),在.net framework 2.0 beta2上测试了一下,已经没有发生两次事件的问题,那这是不是bug? 对于(2)笔者只是对自己提醒一下在不直接选择节点的情况下也会触发AfterSelect事件,在.net framework 2.0 beta2测试结果是一样的。

如果要写些效率高的程序,对于事件的重复触发本人觉得是需要考虑的问题。针对上面的现象,假设在窗体的左边放了一个Treeview表示目录,而右边有个DataGrid,用来根据左边的选择列出对应于目录的产品,如果连续触发两次事件,是不是很恼火,尤其是在数据量大的情况下更是如此。