This is a migrated thread and some comments may be shown as answers.

Customize Group By labels in the group panel

1 Answer 97 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mikhail Diatchenko
Top achievements
Rank 1
Mikhail Diatchenko asked on 17 Jun 2011, 03:55 AM
Is it possible to customize Group By labels in the group panel?
I've looked and the following example (http://www.telerik.com/help/winforms/gridview-grouping-formatting-group-header-row.html) and it only demonstrated how to customise group heading rows, not the labels in group panel.

1 Answer, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 22 Jun 2011, 01:31 PM
Hi Mikhail Diatchenko,

Thank you for writing.

Unfortunately, there is not a straight and easy way to customize group labels in RadGridView. However, you can still achieve that through element hierarchy. Please consider the following sample code:

void radGridView1_GroupByChanged(object sender, GridViewCollectionChangedEventArgs e)
{
    GroupPanelContainer container = this.radGridView1.TableElement.GridViewElement.GroupPanelElement.PanelContainer;
    if (container.Children.Count > 0)
    {
        TemplateGroupsElement groupsElement = (TemplateGroupsElement)container.Children[0];
        foreach (var groupElement in groupsElement.GetChildrenByType(typeof(GroupElement)))
        {
            if (((GroupFieldElement)groupElement.Children[0].Children[0]).Text == "Country")
            {
                ((GroupFieldElement)groupElement.Children[0].Children[0]).Text = "Custom Country Text";
            }
        }
    }
}

Hope this helps. Let me know if you have any additional questions.

All the best,
Martin Vasilev
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Tags
GridView
Asked by
Mikhail Diatchenko
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Share this question
or