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. Image for the cookie policy date

Buttons resize in cell

Hi,
I have a custom cell model with two buttons in it. I want to resize the buttons so that they are of equal size and also resize to fill the cell. Whenever I resize the cell the buttons should grow equally.

thanks
thanvir

1 Reply

HA haneefm Syncfusion Team October 18, 2007 12:09 AM UTC

Hi Thanvir,

You need to override the OnLayout method of the renderer class to set the proper button bounds. In the method, the required position and size can be specified to draw the button in the required size inside the cell. Here is a little sample that puts two elipsis buttons in that covers a gridcell using that override.

protected override Rectangle OnLayout(int rowIndex, int colIndex, GridStyleInfo style, Rectangle innerBounds, Rectangle[] buttonsBounds)
{
TraceUtil.TraceCurrentMethodInfo(rowIndex, colIndex, style, innerBounds, buttonsBounds);

this.Model.ButtonBarSize =new Size(innerBounds.Width,innerBounds.Height);
Rectangle rect = GridUtil.CenterInRect(innerBounds, this.Model.ButtonBarSize);
int width = rect.Width / 2;

buttonsBounds[0] = new Rectangle(rect.X, rect.Y, width, rect.Height);
buttonsBounds[1] = new Rectangle(rect.X + width , rect.Y, width, rect.Height);
return innerBounds;
}

Please refer the attached sample for implementation and let me know if this helps.
ResizeTowButton.zip

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon