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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - Blue

个已实现的例子:通过Javascript在页面中直接调用Office Communicator API - Blue cmd脚本(C# 清缓存) - Blue - 博客园 isql脚本编写创建数据库(SQL Server2000) 怎样踢mstsc占用者 copy:键盘按键和键盘对应代码表 Thread简单概念 Regsvr32命令全攻略 导入导出CVS文件遇到的问题 - Blue - 博客园 一个字段存很多枚举值,然后从字段取出的方法 關於泛型的資料 索引器的两种用法 在建表时使用DEFAULT是很有用的 关于web service的验证 SQL中计算月初和月末 临时表有时很有用 在GROUP语句中还可以增加很多内容 注意insert语句写法 case的用法 尽量减少使用游标
转:ListView 中添加大数据量解决屏幕刷新“闪”的现象
Blue · 2008-08-28 · via 博客园 - Blue

作者:rhythm

  1. ListView 中添加大数据量解决屏幕刷新“闪”的现象。

listview中添加超过10000条或更多的数据时,如果我们一条条添加,屏幕会闪的厉害,如果我们一次性添加,可能我们要等上很长时间才能出现结果。

为了解决(准确的是减轻)这个问题,我们采用ListView的方法AddRange(),配合BeginUpdate() EndUpdate() 使用。

FillListView()

{

     Int TotalRecord = 10008;  //总的记录数

     Int EveryTimeRecord = 100; //每次批量增加的数量

     Int TotalTimes = Math.Floor(TotalRecord / EveryTimeRecord);//批量添加的执行次数

     For(int I = 0; I < TotalTimes; i++)

     {

          ListViewItem[] listViewItems;  //声明listviewitem集合,以便满足AddRange所需的参数

          If(I < TotalTimes - 1)   //I 不是最后一次执行

          {

                   listViewItems = new ListViewItem[initCount];

                   for ( int j  = 0; j < EveryTimeRecord; j++ )

              {

                   int indexRecord = j + i * EveryTimeRecord; // 记录的索引

                   listViewItems[i] = new ListViewItem( );

              listViewItems[i] = AddListViewItem ( batchDocuments[indexRecord] );

}

          }

          Else //最后一次执行,剩下的余数

          {

                   int lastQuantity = TotalRecord - EveryTimeRecord * i;

                   listViewItems = new ListViewItem[lastQuantity];

                   for ( int j = 0; j < lastQuantity; j++ )

                   {

                   int indexRecord = j + i * EveryTimeRecord; // 记录的索引

                   listViewItems[i] = new ListViewItem( );

              listViewItems[i] = AddListViewItem ( batchDocuments[indexRecord] ); //将一个已知listviewitem赋值给声明的listviewitem

              }

}

ListView.BeginUpdate();

               ListView.Items.AddRange( listViewItems );  //利用AddRange批量增加,目的是减少刷屏次数,减轻不断闪烁问题。

ListView.EndUpdate();

     }

}