public new int VirtualListSize
{
get { return base.VirtualListSize; }
set
{
// If the new size is smaller than the Index of TopItem, we need to make
// sure the new TopItem is set to something smaller.
if (VirtualMode &&
View == View.Details &&
TopItem != null &&
value > 0 &&
TopItem.Index > value - 1)
{
TopItem = Items[value - 1];
}
base.VirtualListSize = value;
}
}
我正在尝试设置 listview 的 topitem 属性,但是在虚拟模式下,项目被禁用。所以任何试图在虚拟模式下访问它的代码都会抛出一个无效操作异常。当我尝试逐行调试时不会发生异常。如果我评论该行TopItem=Items[value-1]
,它不会引发任何异常。
System.InvalidOperationException:在 VirtualMode 中,ListView RetrieveVirtualListItem 事件需要每个 ListView 列的列表视图 SubItem。在 System.Windows.Forms.ListView.WmReflectNotify(Message& m) 在 System.Windows.Forms.ListView.WndProc(Message& m) 在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam ) 请建议。