ComponentOne List for WinForms
In This Topic
    Virtualization
    In This Topic

    Data Virtualization enables hassle-free loading of large amount of data in lesser period of time. It enables the List to download only the required screen-display information instead of the whole data.

    The following GIF shows how data virtualization makes it convenient to render a large amount of data in List.

    data virtualization

    List supports virtualization of data to fetch the list of items as the user scrolls in real time. This data virtualization technique is supported in the List through DataCollection which provides C1VirtualDataCollection class for data virtualized collection views.

    To enable virtualization in List, follow these steps:

    1. Define a virtual collection view for by using C1VirtualDataCollection class as shown in the following code. The following code uses the GetPageAsync method to fetch data from the Product class defined in the Quick Start topic.
      C#
      Copy Code
      public class VirtualModeCollectionView : C1VirtualDataCollection<Customer>
          {
              public int TotalCount { get; set; } = 1_000;
      
              protected override async Task<Tuple<int, IReadOnlyList<Product>>> GetPageAsync(int pageIndex, int startingIndex, int count, IReadOnlyList<SortDescription> sortDescriptions = null, FilterExpression filterExpression = null, CancellationToken cancellationToken = default(CancellationToken))
              {
                  await Task.Delay(500, cancellationToken);//Simulates network traffic.
                  return new Tuple<int, IReadOnlyList<Product>>(TotalCount, Enumerable.Range(startingIndex, count).Select(i => new Product(i)).ToList());
              }
          }
      
    2. Bind the virtual collection object with the control using DataSource property of the C1List class.
      C#
      Copy Code
      //begins updating
      c1List1.BeginUpdate();
      var collectionView = new VirtualModeCollectionView();
      //sets the view
      c1List1.DataSource = new C1DataCollectionBindingList(collectionView);
      c1List1.EndUpdate();