Skip to main content

VirtualServerModeSource Class

A data source that features event-based data operations: async data load, sorting, filtering and infinite scrolling through records (in a bound Windows Forms GridControl).

Namespace: DevExpress.Data

Assembly: DevExpress.Data.v24.1.dll

NuGet Package: DevExpress.Data


[ToolboxBitmap(typeof(ResFinder), "Bitmaps256.VirtualServerModeSource.bmp")]
[ToolboxTabName("DX.24.1: Data & Analytics")]
public class VirtualServerModeSource :


The VirtualServerModeSource is an event-based data source for the DevExpress WinForms Data Grid. The data source exposes events that allow you to asynchronously load data in batches and take into account the grid’s sort and filter configuration.

A Data Grid bound to VirtualServerModeSource supports infinite scrolling. On startup, the Data Grid fetches an initial batch of records from the data source. The Data Grid does not know the total number of records in the data source. Its scroll bar always reflects the current number of loaded rows. Once a user scrolls to the last loaded record, the Data Grid requests an additional batch of records and adjusts its scroll bar to match the new loaded record count.


Run Demo: Infinite Scrolling Tutorial


The Data Grid does not support Data Grouping if it is bound to VirtualServerModeSource.

Main Events

The VirtualServerModeSource exposes the following main events:

  • ConfigurationChanged -

    Fires on initial data load and reload in the bound grid control, and when the data grid’s sort and filter configuration changes. Allows you to initialize the data source and (optionally) return an initial batch of records.

  • MoreRows - Fires when a bound grid control asks the data source for a new batch of rows.
using DevExpress.Data;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraGrid;
using System.Collections.Generic;
using System.Windows.Forms;

namespace DXApplication {
   public partial class Form1 : RibbonForm {
       public Form1() {
           VirtualServerModeSource virtualServerModeSource = new VirtualServerModeSource();
           virtualServerModeSource.RowType = typeof(Product);
           virtualServerModeSource.ConfigurationChanged += virtualServerModeSource_ConfigurationChanged;
           virtualServerModeSource.MoreRows += virtualServerModeSource_MoreRows;
           GridControl gridControl = new GridControl();
           gridControl.Parent = this;
           gridControl.Dock = DockStyle.Fill;
           gridControl.DataSource = virtualServerModeSource;

       int batchSize = 20;
       int maxRowCount = 500;
       private void virtualServerModeSource_ConfigurationChanged(object sender, DevExpress.Data.VirtualServerModeRowsEventArgs e) {
           e.UserData = GetRows(0);

       private void virtualServerModeSource_MoreRows(object sender, DevExpress.Data.VirtualServerModeRowsEventArgs e) {
           e.RowsTask = System.Threading.Tasks.Task.Factory.StartNew(() => {
               bool moreRows = e.CurrentRowCount < maxRowCount - batchSize;
               return new VirtualServerModeRowsTaskResult(GetRows(e.CurrentRowCount), moreRows, e.UserData);
           }, e.CancellationToken);

       List<Product> GetRows(int startRowIndex) {
           List<Product> lst = new List<Product>();
           for (int i = startRowIndex; i < startRowIndex + batchSize; i++)
               lst.Add(new Product { ID = i, Name = $"Product{i}" });
           return lst;
   public class Product {
       public int ID { get; set; }
       public string Name { get; set; }

Additional Events

The following events allow you to control data shaping operations invoked in the bound Data Grid control and enable CRUD operations:

  • GetUniqueValues - Allows you to provide values for columns’ filter dropdowns.
  • TotalSummary - Fires when a grid control asks the data source to calculate total summaries.
  • CanPerformColumnServerAction - Allows you to specify whether the requested filtering, sorting or summary calculation operation needs to be accepted or canceled.
  • AcquireInnerList -

    This event can be handled to provide an inner list that will be storage for rows fetched using the VirtualServerModeSource’s events. To enable CRUD operations in a bound Data Grid, you need to provide an inner list that supports these operations. If no inner list is supplied (or you do not handle the AcquireInnerList event), CRUD operations are disabled in the grid control.

Specify the VirtualServerModeSource.RowType property at design time to populate the bound grid control with columns.

If the RowType property is not specified, handle the AcquireInnerList event to manually supply a list that will store rows fetched by VirtualServerModeSource’s events.


See Also