Edit this page

Getting Started

This tutorial will walk you through the required steps for using RadVirtualGrid.

Assembly References

In order to use RadVirtualGrid in your application, you need to add references to the following assemblies:

  • Telerik.Windows.Controls
  • Telerik.Windows.Controls.VirtualGrid
  • Telerik.Windows.Data

Adding RadVirtualGrid to the Project

[XAML] Example 1: Defining RadVirtualGrid Declaratively

 <telerik:RadVirtualGrid x:Name="VirtualGrid"/>

Setting Initial Row and Column Count

RadVirtualGrid needs to be initially populated with fixed amount of rows and columns. The below listed properties are exposed for achieving this. An important note is that when additional rows or columns are added at runtime, the values of these properties remain unmodified, but the capacity of the control increases. More information on inserting rows and columns can be found in the Insert and Remove Data topic.

  • InitialRowCount: Gets or sets the amount of initially loaded rows

  • InitialColumnCount: Gets or sets the amount of initially loaded columns

[XAML] Example 2: Setting the InitialRowCount and InitialColumnCount properties

<telerik:RadVirtualGrid x:Name="VirtualGrid" 

Populating with Data through DataProvider

When populating data with a DataProvider, it handles most of the operations of RadVirtualGrid out-of-the-box. Thus, the events that are intended to be used for manually populating and manipulating the data of the control will not be raised.

Instead of using the CellValueNeeded event, RadVirtualGrid provides an option to populate its data through the built-in DataProvider mechanism. The DataProvider object accepts an IEnumerable through its constructor and can be applied to RadVirtualGrid through its relevant property.

[C#] Example 4: Applying a DataProvider

this.VirtualGrid.DataProvider = new Telerik.Windows.Controls.VirtualGrid.DataProvider(this.myCollection);

The DataProvider mechanism is intended to cover basic scenarios for populating the control with data. For extending the default behavior, RadVirtualGrid provides support for Custom DataProvider

Populating with data manually

In order the control to be populated with data, its InitialRowCount and InitialColumnCount properties need to be set.

The control populates its data through the CellValueNeeded event. It is raised when the control is initially loaded and when newly data is about to be loaded on demand when the user scrolls horizontally or vertically. The event arguments expose the following properties:


  • CellIndex: Provides information regarding the index of the currently loaded cell.

  • RowIndex: Provides information regarding the index of the currently loaded row.

  • Value: Through it the needed value for the respective cell can be set.

[C#] Example 3: Populating RadVirtualGrid with data through the CellValueNeeded event

private void virtualGrid_CellValueNeeded(object sender, 
        Telerik.Windows.Controls.VirtualGrid.CellValueEventArgs e)
        e.Value = String.Format("{0}.{1}", e.RowIndex, e.ColumnIndex);

Figure 1: RadVirtualGrid populated with data

RadVirtualGrid populated with data

Resetting the Capacity to the Initial Row and Column Count

As inserting rows and columns does not affect the InitialRowCount and InitialColumnCount properties, RadVirtualGrid supports resetting its capacity to the values that are set to them. This can be done through the following methods:

  • Reset(): Resets the capacity of the control to the values of the InitialRowCount and InitialColumnCount properties.

  • Reset(int rowCount, int columnCount): Through this overload of the Reset method, the capacity of RadVirtualGrid can be reset to values different from the ones initially set to the InitialRowCount and InitialColumnCount properties. Furthermore, the two properties will be updated accordingly.

See also