)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

What is a virtual grid in WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: December 18, 2019

Virtual grid

A Virtual Grid does not hold any data. All data is supplied to the Grid, from an external data source, on demand. When the Grid needs a particular cell, say to draw it, it asks the external data source for that value. Since no data is actually loaded into the Grid, there is virtually no limit imposed by Essential Grid on the number of rows and columns you can have.

C#

//Hook the below events in Form_Load to have a virtual grid
gridControl1.QueryCellInfo += gridControl1_QueryCellInfo;
gridControl1.QueryRowCount += gridControl1_QueryRowCount;
gridControl1.QueryColCount += gridControl1_QueryColCount;    
private void gridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
    if (e.ColIndex > 0 && e.RowIndex > 0)
    {
        e.Style.Text = string.Format("R{0}:C{1}", e.RowIndex, e.ColIndex);
        e.Handled = true;
    }
}        
private void gridControl1_QueryRowCount(object sender, GridRowColCountEventArgs e)
{
    //Set RowCount
    e.Count = 1000;
    e.Handled = true;
}
private void gridControl1_QueryColCount(object sender, GridRowColCountEventArgs e)
{
    //Set ColCount 
    e.Count = 100;
    e.Handled = true;
}

VB

'Hook the below events in Form_Load to have a virtual grid
gridControl1.QueryCellInfo += gridControl1_QueryCellInfo
gridControl1.QueryRowCount += gridControl1_QueryRowCount
gridControl1.QueryColCount += gridControl1_QueryColCount
Private Sub gridControl1_QueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
    If e.ColIndex > 0 AndAlso e.RowIndex > 0 Then
           e.Style.Text = String.Format("R{0}:C{1}", e.RowIndex, e.ColIndex)
           e.Handled = True
    End If
End Sub
Private Sub gridControl1_QueryRowCount(ByVal sender As Object, ByVal e As GridRowColCountEventArgs)
    'Set RowCount
    e.Count = 1000
    e.Handled = True
End Sub
Private Sub gridControl1_QueryColCount(ByVal sender As Object, ByVal e As GridRowColCountEventArgs)
    'Set ColCount 
    e.Count = 100
    e.Handled = True
End Sub

 

The following screenshot displays the Virtual Grid.

Virtual grid in GridControl

Figure 1: Virtual Grid

Samples:

C#: VirtualGrid

VB:

VirtualGrid

Reference Link: https://help.syncfusion.com/windowsforms/grid-control/virtual-grid

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
Ildar Sadykov
Dec 08, 2015
All reference links are broken. Reply
Mohanraj Gunasekaran [Syncfusion]
Dec 11, 2015
Hi IIdar, Broken link has been resolved. Reply

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon