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.
Syncfusion Feedback

Resizing header only

Thread ID:

Created:

Updated:

Platform:

Replies:

29366 May 24,2005 02:08 PM UTC May 24,2005 07:09 PM UTC Windows Forms 4
loading
Tags: GridControl
Stephane SansCartier
Asked On May 24, 2005 02:08 PM UTC

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 04:22 PM UTC

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 06:21 PM UTC

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 06:32 PM UTC

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 07:09 PM UTC

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.

Warning Icon 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.Close Icon

;