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

Column resize questions

Hi all,

I've got a couple of questions regarding double-clicking on the header separator to automatically resize a column.

First I've got a grid with about 10 columns, 3 of which are hidden. I've hidden them by setting grid.HideCols[i] = true for the appropriate column indexes. This works most of the time, but if the user double-clicks on the right most header bar to resize the right-most column, all of the hidden columns suddenly appear.

Also I've told the columns to resize on whichever is larger, the column header or the widest content of the column, by using this setting:

_gridOrders.Model.ColWidths.ResizeToFit(sfGrid.GridRangeInfo.Table(), sfGrid.GridResizeToFitOptions.IncludeHeaders | sfGrid.GridResizeToFitOptions.NoShrinkSize)

That works most of the time, but if the user double-clicks on the column header separator the column resizes to the width of the header text. I'd like to have it to use the same rules when resizing that way that it does when it first opens up.

Are there events related to the header double-click? I haven't been able to find them.

Thanks in advance for any tips!

Chris

3 Replies

AD Administrator Syncfusion Team March 2, 2007 03:07 PM UTC

Hi Chris,

This is the default behavior. If you dont want this, then handle the ResizingColumns event of the grid and set e.Cancel to true when its a doubleclick. This will help you.

private void gridControl1_ResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
if(e.Reason == GridResizeCellsReason.DoubleClick)
e.Cancel = true;
}


Best regards,
Haneef


AD Administrator Syncfusion Team March 2, 2007 03:15 PM UTC

Hi Haneef,

Thanks for the fast reply. When you say 'this' is the default behavior, I assume you mean that it resizes the columns to the header width. That's fine, and I can use the code you included to avoid that behavior.

But what about the behavior where it exposes all the hidden columns? That seems like a bug, or at least some kind of configuration error on my part.

Chris

>Hi Chris,

This is the default behavior. If you dont want this, then handle the ResizingColumns event of the grid and set e.Cancel to true when its a doubleclick. This will help you.

private void gridControl1_ResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
if(e.Reason == GridResizeCellsReason.DoubleClick)
e.Cancel = true;
}


Best regards,
Haneef


AD Administrator Syncfusion Team March 2, 2007 03:20 PM UTC

Never mind, that fix seemed to make it stop exposing the hidden columns too. Thanks!

Chris

>Hi Haneef,

Thanks for the fast reply. When you say 'this' is the default behavior, I assume you mean that it resizes the columns to the header width. That's fine, and I can use the code you included to avoid that behavior.

But what about the behavior where it exposes all the hidden columns? That seems like a bug, or at least some kind of configuration error on my part.

Chris

>Hi Chris,

This is the default behavior. If you dont want this, then handle the ResizingColumns event of the grid and set e.Cancel to true when its a doubleclick. This will help you.

private void gridControl1_ResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
if(e.Reason == GridResizeCellsReason.DoubleClick)
e.Cancel = true;
}


Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon