System.Windows.Forms.ListView.VirtualMode Property

Gets or sets a value indicating whether you have provided your own data-management operations for the System.Windows.Forms.ListView control.

Syntax

[System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)]
[System.ComponentModel.DefaultValue(false)]
public bool VirtualMode { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

Setting the ListView.VirtualMode property to true puts the System.Windows.Forms.ListView into virtual mode. In Virtual mode, the normal ListView.Items collection is unused. Instead, System.Windows.Forms.ListViewItem objects are created dynamically as the System.Windows.Forms.ListView requires them.

Virtual mode can be useful under many circumstances. If a System.Windows.Forms.ListView object must be populated from a very large collection already in memory, creating a System.Windows.Forms.ListViewItem object for each entry can be wasteful. In virtual mode, only the items required are created. In other cases, the values of the System.Windows.Forms.ListViewItem objects may need to be recalculated frequently, and doing this for the whole collection would produce unacceptable performance. In virtual mode, only the required items are calculated.

In order to use virtual mode, you must handle the ListView.RetrieveVirtualItem event, which is raised every time the System.Windows.Forms.ListView requires an item. This event handler should create the System.Windows.Forms.ListViewItem object that belongs at the specified index. In addition, the ListView.VirtualListSize property must be set to the size of the virtual list.

Handling the ListView.SearchForVirtualItem event enables searching in virtual mode. If this event is not handled, the ListView.FindItemWithText(string) and ListView.FindNearestItem(SearchDirectionHint, int, int) methods will return null.

You can handle the ListView.CacheVirtualItems event in order to maintain a cache of System.Windows.Forms.ListViewItem objects. If the calculation or lookup to create a System.Windows.Forms.ListViewItem object is expensive, maintaining a cache can improve performance.

If the ListView.View property is set to View.Tile, the value will automatically be changed to View.LargeIcon when ListView.VirtualMode is set to true.

In virtual mode, the ListView.Items collection is disabled. Attempting to access it results in an InvalidOperationException. The same is true of the ListView.CheckedItems collection and the ListView.SelectedItems collection. If you want to retrieve the selected or checked items, use the ListView.SelectedIndices and ListView.CheckedIndices collections instead.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0