New to Telerik UI for WinForms? Download free 30-day trial

Access RadGridView Elements


Product Version 2018.3.1016
Product RadGridView for WinForms
Author Desislava Yordanova


In version R3 2018 SP1 (2018.3.1016) we have introduced a new feature in RadGridView, displaying a caption. This requires a changing the element hierarchy and if you have existing code that accesses the elements by index (can be serialized at design time as well) you will get an exception.

Access the elements by index

var groupPanel = this.radGridView1.GridViewElement.Children[0].Children[0].Children[0] as GroupPanelElement;
Dim groupPanel = TryCast(Me.radGridView1.GridViewElement.Children(0).Children(0).Children(0), GroupPanelElement)


This causes exception because the index of the GroupPanelElement is no longer valid. One solution to this is to change the index to 1.

Another solution is to use the property to access the element. For example:

var groupPanel = this.radGridView1.GridViewElement.GroupPanelElement;

Dim groupPanel = this.radGridView1.GridViewElement.GroupPanelElement

If the is no property you can get the element by type by using the following method:

var groupPanel = this.radGridView1.GridViewElement.GetChildrenByType(typeof(GroupPanelElement)).FirstOrDefault();

Dim groupPanel = Me.radGridView1.GridViewElement.GetChildrenByType(GetType(GroupPanelElement)).FirstOrDefault()

In this article