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

fit the width of collumn by double-click on collumn header

Hi,
I want to fit the collumn-width when the user double-clicks on the header of the grid. So far I use this code:
private void gridControl1_ResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
if (e.Reason == GridResizeCellsReason.DoubleClick)
{
if (e.Columns.IsCols == true)
{
gridControl1.ColWidths.ResizeToFit(e.Columns);
}
}
}

But this code does not work. What's wrong? Thank you, Dan

2 Replies

AD Administrator Syncfusion Team March 8, 2007 06:21 PM UTC

Hi Dan,

You can try setting e.Cancel to true for DoubleClick reason in ResizingColumns event and let me know if this helps.

private void gridControl1_ResizingColumns(object sender, Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventArgs e)
{
if (e.Reason == GridResizeCellsReason.DoubleClick)
{
if (e.Columns.IsCols == true)
{
gridControl1.ColWidths.ResizeToFit(e.Columns);
e.Cancel = true;
}
}
}

Best regards,
Haneef


AD Administrator Syncfusion Team March 9, 2007 07:26 AM UTC

Hi Haneef,
yes it helped, thank you :-). Dan

Loader.
Live Chat Icon For mobile
Up arrow icon