本文对于ListView闪烁的原因,进行探究,并对于不同种的情况给出解决方案。
闪烁的原因
ListView闪烁的原因有以下几点或几种情况:
1:在数据多次插入间,存在时间间隔。
2:。
3:界面上有多个ListView在进行数据插入。
最根本的原因是因为,每次调用ListView实例进行插入的时候,都需要向系统发送一个窗口消息(相信做C++的朋友应该很清楚),然后窗口接到消息就会刷新对应控件的界面。所以,如果间隔时间长,或插入次数多,一定会闪烁的。
解决方案
源码中实例的解决方案:
ListViewItem lvi;
ListViewItem[] lvitems1 = new ListViewItem[10000];
for (int i = 0; i < 10000; i++)
{
lvi = new ListViewItem(new string[] { (), "22" });
lvitems1[i] = lvi;
}
(lvitems1);更通用的解决方法:
// create a temp dataTable to store data
DataTable dt = new DataTable();
DataRow dr;
("ID", typeof(String));
("Name", typeof(String));
("Class", typeof(String));
("Lesson", typeof(String));
foreach(item in dataSource)
{
dr = ();
dr[0] = ; // ID
dr[1] = ; // Name
dr[2] = ; // Class
dr[3] = ; // Lesson
(dr);
}
// loop the temp table , and insert to ListView
int i = 0;
while(iint iSize = (
解决ListView闪烁问题 来自淘豆网m.daumloan.com转载请标明出处.