AD
Administrator
Syncfusion Team
November 25, 2004 08:24 AM
The 3.0 code ships with a sample, Syncfusion\Essential Suite\3.0.0.19\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. http://64.78.18.34/Support/Forums/message.aspx?MessageID=15027
Here are some other forum links that show other ways you can customized the caption.
http://64.78.18.34/Support/Forums/message.aspx?MessageID=19716
http://64.78.18.34/Support/Forums/message.aspx?MessageID=11530
DH
Devshi Halai
November 30, 2004 03:16 AM
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.
AD
Administrator
Syncfusion Team
November 30, 2004 09:54 AM
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