How to implement a minimal virtual grid in WinForms GridControl?
Virtual grid
There are
three steps that you have to follow in order to implement a read-only in
the WinForms GridControl. In the QueryCellInfo,
provide the actual data from your external data source. In the QueryRowCount,
provide the number of rows that are in the virtual grid, and in
the QueryColCount, provide the number of columns in the virtual
grid.
//Hook the Events in Form_Load.
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_QueryColCount(object sender, GridRowColCountEventArgs e)
{
e.Count = 100;
e.Handled = true;
}
private void gridControl1_QueryRowCount(object sender, GridRowColCountEventArgs e)
{
e.Count = 1000;
e.Handled = true;
}'Hook the Events in Form_Load.
AddHandler Me.gridControl1.QueryCellInfo, AddressOf gridControl1_QueryCellInfo
AddHandler Me.gridControl1.QueryRowCount, AddressOf gridControl1_QueryRowCount
AddHandler Me.gridControl1.QueryColCount, AddressOf 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_QueryColCount(ByVal sender As Object, ByVal e As GridRowColCountEventArgs)
e.Count = 100
e.Handled = True
End Sub
Private Sub gridControl1_QueryRowCount(ByVal sender As Object, ByVal e As GridRowColCountEventArgs)
e.Count = 1000
e.Handled = True
End Sub Note:
To change the value of the cell, add the SaveCellInfo event.

Figure 1: Virtual grid
Samples:
C#: MinimalVirtualGrid
Reference Link: Virtual Grid