简体   繁体   中英

Adding a Button in Summary Row - RadGrid Telerik Winforms

I have a summary row on top of my grid which count ID column. I need to add a Button in this summary row on V column. Is this possible? How?

在此处输入图片说明

You can handle ViewCellFormatting event handler like this. I am not certain when should be the best time to add a new button element inside the summary cell, but the check for children's number ensures that the element will be added only once at the beginning. Alternatively you can just place an image in the current summary cell element, but the pushing effect will not be available.

private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement.ColumnInfo.Name == "V" && e.CellElement is GridSummaryCellElement)
    {
        // adding a new button element
        if (e.CellElement.Children.Count == 0)
        {
            var element = new RadButtonElement();
            element.Margin = new Padding(12, 0, 12, 0);
            element.ImageAlignment = ContentAlignment.MiddleCenter;
            element.Alignment = ContentAlignment.MiddleCenter;
            e.CellElement.Children.Add(element);
        }

        // or setting an image to the current element
        //e.CellElement.Image = Properties.Resources.FilterImage;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.TextAlignmentProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.FontProperty, ValueResetFlags.Local);
    }
}

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM