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

Applying formatting only to cells in a child template

Updated over 6 months ago

If the parent of the view template is not null, the cell element is located in a child template.

Example 1

This idea is used in the code snippet below so that the BackColor of the cells located only in the child templates is changed:

Changing the cells BackColor for cells located in a child template

C#
void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement.ViewTemplate.Parent != null)
    {
        e.CellElement.BackColor = Color.Yellow;
        e.CellElement.NumberOfColors = 1;
        e.CellElement.DrawFill = true;
    }
}

 Example 2

You can use the following code snippet to change the header height of the first level child template:

Changing the child template header row height

C#
void radGridView1_ViewCellFormatting1(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement.ViewTemplate.Parent != null)
    {
        e.CellElement.TableElement.TableHeaderHeight = 100;
    }
}

See Also

In this article
Example 1Example 2See Also
Not finding the help you need?
Contact Support