I have it ListViewin virtual mode, and the underlying data is stored in List<MyRowObject>. Each column ListViewcorresponds to a public string property MyRowObject. My columns are ListViewcustomizable at runtime, so any of them can be disabled and can be changed. To return ListViewItemfor an event RetrieveVirtualItem, I have a method similar to:
class MyRowObject
{
public string[] GetItems(List<PropertyInfo> properties)
{
string[] arr = new string[properties.Count];
foreach(PropertyInfo property in properties)
{
arr[i] = (string)property.GetValue(this,null);
}
return arr;
}
}
The event handler for RetrieveVirtualItemlooks like this:
private void listView_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
{
e.Item = new ListViewItem(_virtualList[e.ItemIndex].GetItems(_currentColumns));
}
Perhaps it is not surprising that benchmarking shows that this method is much slower than an implementation that accessed properties directly in hard-coded order, and slowdown is significant enough that I would like to find a better solution.
, , , MyRowObject, , , ( , , , ?).
, ListView - ?
ListView .