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.

Resizing header only

Thread ID:

Created:

Updated:

Platform:

Replies:

29366 May 24,2005 10:08 AM May 24,2005 03:09 PM Windows Forms 4
loading
Tags: GridControl
Stephane SansCartier
Asked On May 24, 2005 10:08 AM

Hi, How can I set the grid so that the user can only resize the column header vertically (only the first row must be resizable)? In the ResizeRowsBehavior I only see Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.IgnoreHeaders which is the opposite of what I need to do. Thank

Administrator [Syncfusion]
Replied On May 24, 2005 12:22 PM

If you want to do special hit testing to decide exactly when you want to allow sizing, you should set the insidegrid flag in the ResizingCOlsBehavior property and handle the ResizingColumns event. Here is code that only allows resizing in row 1.
private void gridDataBoundGrid1_ResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
	if(e.Reason == GridResizeCellsReason.HitTest)
	{
		int row, col;
		if(this.gridDataBoundGrid1.PointToRowCol(e.Point, out row, out col)
			&& row != 1)
		{
			e.Cancel = true;
		}
	}
}

Stephane SansCartier
Replied On May 24, 2005 02:21 PM

Great! And how would I set a minimum size? I don’t want the user to hide the column header and not be able to see it (for some reason, when the user resizes the header to 0, he can not resize it to see it again).

Administrator [Syncfusion]
Replied On May 24, 2005 02:32 PM

You can handle ColWidthChanging and cancel the changes if necessary. You would also want to handle ColumnsHiding to prevent the user from hiding the column by sizing it to zero (if you want to avoid this).
 
private void gridControl1_ColWidthsChanging(object sender, GridRowColSizeChangingEventArgs e)
{
        if(e.From == 2 && e.Values[0] > 200 || e.Values[0] < 50)
              e.Cancel = true;
}
Here is a sample.

Stephane SansCartier
Replied On May 24, 2005 03:09 PM

Everything is working, thank!

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.

;