We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grouping Grid Caption Row buttons, columns

Thread ID:





21876 Nov 25,2004 09:11 AM UTC Nov 30,2004 02:54 PM UTC WinForms 3
Tags: GridControl
Devshi Halai
Asked On November 25, 2004 09:11 AM UTC

How can I add buttons to the Group Caption Row of a grouping grid. I need these buttons so that I may perform an action on all the records in a group. Also How can I create a cell in the group caption row so that I may display some related data. Thanks Dev.

Administrator [Syncfusion]
Replied On November 25, 2004 01:24 PM UTC

The 3.0 code ships with a sample, Syncfusion\Essential Suite\\Windows\Grid.Windows\Samples\Grouping\CustomCellTypes, that shows how to put a button in a header cell. Here is a forum thread on showing summary cells in a caption. Here are some other forum links that show other ways you can customized the caption.

Devshi Halai
Replied On November 30, 2004 08:16 AM UTC

Thanks Clay, I''ve got the button on the GroupCaptionCell, by default it appears on the right of the GroupCaptionCell, how can I place the button at any position on the GroupCaptionCell ? My second question is how can I also put extra cells on the GroupCaptionCell. I need to add two extra cells into the GroupCaptionCell ? Thanks Dev.

Administrator [Syncfusion]
Replied On November 30, 2004 02:54 PM UTC

Hi Dev, check out the samples D:\Essential Suite\Windows\Grid.Grouping.Windows\Samples\CustomSectionInGroup and SummaryInCaption It shows how you can handle the TableModel.QueryCoveredRange events and TableModel.QueryCellStyleInfo events in order to place your own contents inside a caption bar or any extra sections of a group To place the button of a custom cell type at a different position you need to do this in the renderers on OnLayout override. First, try to save a reference to the the button when you instantiate it with this.AddButton(new MyCellButton(this)); for example add them to your own ArrayList. ArrayList al = new ArrayList; al.Add(new MyCellButton(this)); this.AddButton((MyCellButton) al[0]); Then you have full access to all buttons. In order to show/hide or position buttons individually you can override the OnLayout method and position buttons or set bounds empty for those you do not want to show. Here is the default implementation of this method: protected virtual Rectangle OnLayout(int rowIndex, int colIndex, GridStyleInfo style, Rectangle innerBounds, Rectangle[] buttonsBounds) { Rectangle clientRectangle = innerBounds; int count = Buttons.Count; if (!Grid.IsPrinting() && count > 0 && this.OnQueryShowButtons(rowIndex, colIndex, style)) { innerBounds.Inflate(-1, -1); int nButtonBarWidth = Model.ButtonBarSize.Width; int width = nButtonBarWidth / count; clientRectangle.Width -= nButtonBarWidth; int height = Math.Min(Model.ButtonBarSize.Height, innerBounds.Height); if (height == 0) height = innerBounds.Height; GridTextAlign textAlign = style.TextAlign; GridVerticalAlignment verticalAlign = style.VerticalAlignment; int yOffset = innerBounds.Top; if (verticalAlign == GridVerticalAlignment.Middle) yOffset += (innerBounds.Height - height)/2; else if (verticalAlign == GridVerticalAlignment.Bottom) yOffset += (innerBounds.Height - height); int xOffset = innerBounds.Left; if ((style.TextAlign == GridTextAlign.Right) != Grid.IsRightToLeft()) clientRectangle.Offset(nButtonBarWidth, 0); else xOffset += innerBounds.Width - nButtonBarWidth; for (int n = 0; n < count; n++) { Rectangle bounds = new Rectangle(xOffset, yOffset, width, height); buttonsBounds[n] = bounds; xOffset += width; } } return clientRectangle; } What is most interesting for you is in the end setting the butonsBounds. You don’t have to worry about the other code, just do something like this: protected override Rectangle OnLayout(int rowIndex, int colIndex, GridStyleInfo style, Rectangle innerBounds, Rectangle[] buttonsBounds) { Rectangle clientRectangle = Base.OnLayout(…); // Position button 0 buttonsBounds[0] = new Rectangle(x, y, width, height); return clientRectangle; } Stefan


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon