本文整理汇总了C#中System.Windows.Forms.ListView.CacheVirtualItems事件的典型用法代码示例。如果您正苦于以下问题:C# ListView.CacheVirtualItems事件的具体用法?C# ListView.CacheVirtualItems怎么用?C# ListView.CacheVirtualItems使用的例子?那么恭喜您, 这里精选的事件代码示例或许可以为您提供帮助。您也可以进一步了解该事件所在类System.Windows.Forms.ListView
的用法示例。
在下文中一共展示了ListView.CacheVirtualItems事件的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: listView1_CacheVirtualItems
//Manages the cache. ListView calls this when it might need a
//cache refresh.
void listView1_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e)
{
//We've gotten a request to refresh the cache.
//First check if it's really neccesary.
if (myCache != null && e.StartIndex >= firstItem && e.EndIndex <= firstItem + myCache.Length)
{
//If the newly requested cache is a subset of the old cache,
//no need to rebuild everything, so do nothing.
return;
}
//Now we need to rebuild the cache.
firstItem = e.StartIndex;
int length = e.EndIndex - e.StartIndex + 1; //indexes are inclusive
myCache = new ListViewItem[length];
//Fill the cache with the appropriate ListViewItems.
int x = 0;
for (int i = 0; i < length; i++)
{
x = (i + firstItem) * (i + firstItem);
myCache[i] = new ListViewItem(x.ToString());
}
}