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
close icon

Handling the double click on header borders

Hello,

When the user double clicks on the header border the size of the column is reset to the default width by default.

I'd like to resize the column to be just large enough to fit the contents of all the cells in.

Is there an event I can add a handler to to do this?

Thanks,
Ben

1 Reply

GR Golda Rebecal Syncfusion Team September 17, 2007 11:38 AM UTC

Hi Ben,

Sorry for the delay in responding.

You can make the column fit to text on resize double click by using the ResizeToFit method in the ResizingColumns event.

void gridControl1_ResizingColumns(object sender, Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventArgs e)
{
if (e.Reason.Equals(GridResizeCellsReason.DoubleClick))
{
e.Cancel = true;

this.gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Cols(e.Columns.Left,e.Columns.Left));
}
}

Please try this and let me know if this helps you.

We appreciate your interest in Syncfusion products.

Best regards,
Golda

Loader.
Live Chat Icon For mobile
Up arrow icon