How do I get the start index and number of visible items in a ListView?

前端 未结 7 1950
迷失自我
迷失自我 2020-12-21 02:37

I have a listview working in virtual mode, in the LargeIcons view. Retrieves are expensive, so I want to ask for the data for all the visible items. How do I get the start

7条回答
  •  温柔的废话
    2020-12-21 03:27

    foreach (var t in listView1.Items)
    {                        
    
        var lvitem = listView1.ItemContainerGenerator.ContainerFromItem(t) as ListViewItem;                   
        if (lvitem == null) continue;
        //lvitem will = null if it is not visible 
    
        // otherwise do stuff with lvitem such as:
        lvitem.Foreground = Brushes.Green;
    
    }
    

提交回复
热议问题