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.
Unfortunately, activation email could not send to your email. Please try again.

Column resize questions

Thread ID:

Created:

Updated:

Platform:

Replies:

57377 Mar 2,2007 09:52 AM Mar 2,2007 10:20 AM Windows Forms 3
loading
Tags: GridControl
Chris
Asked On March 2, 2007 09:52 AM

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

Administrator [Syncfusion]
Replied On March 2, 2007 10:07 AM

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

Administrator [Syncfusion]
Replied On March 2, 2007 10:15 AM

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

Administrator [Syncfusion]
Replied On March 2, 2007 10:20 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;