ComponentOne FlexGrid for WinForms
Data Binding / Data Virtualization
In This Topic
    Data Virtualization
    In This Topic

    FlexGrid supports data virtualization for faster performance for very large data sets. With virtual mode, data is fetched in pages as the user scrolls. The grid knows the total number of rows but only loads and displays those that are visible to the user.

    For example, you can use C1.DataCollection package to implement virtualizable data source. You should create a class inherited from the C1VirtualDataCollection and implement GetPageAsync method which returns one page of data from data source of your choice.

    The following GIF shows how the FlexGrid appears in virtual scrolling mode.

    Below code example demonstrates how to enable Virtual Scrolling in the FlexGrid by creating an instance of C1VirtualDataCollection class.

    public class VirtualModeCollectionView : C1VirtualDataCollection<Customer>
    {
       public int TotalCount { get; set; } = 1_000;
       protected override async Task<Tuple<int, IReadOnlyList<Customer>>> 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<Customer>>(TotalCount, Enumerable.Range(startingIndex, count).Select(i => new Customer(i)).ToList());
       }
    }