How to speed adding items to a ListView?

前端 未结 5 466
温柔的废话
温柔的废话 2020-12-04 11:47

i\'m adding a few thousand (e.g. 53,709) items to a WinForms ListView.

Attempt 1: 13,870 ms

foreach (Object o in list)
         


        
5条回答
  •  旧巷少年郎
    2020-12-04 12:42

    ListView Box Add

    This is simple code I was able to construct to add Items to a listbox that consist of columns. The first column is item while the second column is price. The code below prints Item Cinnamon in first column and 0.50 in the second column.

    // How to add ItemName and Item Price
    listItems.Items.Add("Cinnamon").SubItems.Add("0.50");
    

    No instantiation needed.

提交回复
热议问题