---
title: "GridControl loading data from database in virtual mode"
published_at: "2012-04-10T06:09:00+00:00"
modified_at: "2025-03-18T13:56:15+00:00"
url: "https://www.syncfusion.com/blogs/post/gridcontrol-loading-data-from-database-in-virtual-mode"
excerpt: "The Syncfusion Windows Forms GridControl is a high performance Grid that is capable of loading data in virtual. In this sample, the Grid pages in data from a SQL Server database when scrolled. Download sample: WF_GCPagingVirtualDB.zip private void gridControl1_QueryCellInfo(object sender,..."
taxonomy_category:
  - "Desktop"
  - "Development"
  - "Grid"
  - "Windows Forms"
---

# GridControl loading data from database in virtual mode

[Davis Jebaraj](https://www.syncfusion.com/blogs/author/davisj)

![Image](https://www.syncfusion.com/blogs/wp-content/uploads/2018/08/dataloading_database_da7dba06.png)


The Syncfusion Windows Forms GridControl is a high performance Grid that is capable of loading data in virtual. In this sample, the Grid pages in data from a SQL Server database when scrolled.

**Download sample:** [WF_GCPagingVirtualDB.zip](https://www.syncfusion.com/downloads/Support/DirectTrac/92773/WF_GCPagingVirtualDB-1939334767.zip)

```
private void gridControl1_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
        {
            if (e.RowIndex == 0 && e.ColIndex > 0)
            {
                e.Style.Text = retriever.Columns[e.ColIndex - 1].ColumnName;
            }
            else if (e.RowIndex > 0 && e.ColIndex > 0)
            {
                if (this.myData == null || this.myData.RowCount == 0)
                    return;

                if (this.myData.EnsureDataAvailable(e.RowIndex))
                {
                    int rowPos = e.RowIndex - this.gridControl1.Rows.HeaderCount -           this.myData.StartRow - 1;

                    if (rowPos >= this.myData.ActiveTable.Rows.Count)
                        return;
                    int colPos = e.ColIndex - this.gridControl1.Cols.HeaderCount - 1;
                    e.Style.CellValue = this.myData.ActiveTable.Rows[rowPos][colPos];
                    e.Style.BackColor = this.myData.ActiveTableColor;
                }
            }
        }
```

![image](https://blog.syncfusion.com/wp-content/uploads/2018/08/image-5.png "image")
