为了解决(准确的是减轻)这个问题,我们采用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(); } }
http://www.cnblogs.com/qianxudetianxia/archive/2011/08/04/2088493.html
http://blog.csdn.net/flowingflying/article/details/6846991
http://topic.csdn.net/u/20110310/11/0ea9099a-1e43-4f71-80d6-87908df21881.html
http://www.eoeandroid.com/thread-75930-1-1.html
http://gnibre.iteye.com/blog/804336