New to Telerik UI for WinFormsStart a free 30-day trial

Access RadGridView Elements

Updated over 6 months ago

Environment

Product Version2018.3.1016
ProductRadGridView for WinForms
AuthorDesislava Yordanova

Description

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

C#
var groupPanel = this.radGridView1.GridViewElement.Children[0].Children[0].Children[0] as GroupPanelElement;

Solution

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:

C#

var groupPanel = this.radGridView1.GridViewElement.GroupPanelElement;

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

C#

var groupPanel = this.radGridView1.GridViewElement.GetChildrenByType(typeof(GroupPanelElement)).FirstOrDefault();
In this article
EnvironmentDescriptionSolution
Not finding the help you need?
Contact Support