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

Thread ID:

Created:

Updated:

Platform:

Replies:

6380 Aug 11,2003 09:53 AM Dec 22,2005 02:22 AM Windows Forms 2
loading
Tags: FAQ
mark
Asked On August 11, 2003 09:53 AM

tried the code for preventing column resize and it does not work.still able to grab the column in the column header and resize the datagrid. am i missing something? 5.44 How can I prevent my user from sizing columns in my datagrid? You can do this by subclassing your grid and overriding OnMouseMove, and not calling the baseclass if the point is on the columnsizing border. [C#] public class MyDataGrid : DataGrid { protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e) { DataGrid.HitTestInfo hti = this.HitTest(new Point(e.X, e.Y)); if(hti.Type == DataGrid.HitTestType.ColumnResize) { return; //no baseclass call } base.OnMouseMove(e); } }

john
Replied On May 11, 2004 04:15 AM

Just in case anybody else has this problem, it seems you also have to do the same test mentioned here in OnMouseDown, or the user will still be able to grab and move the divider between columns.

Administrator [Syncfusion]
Replied On December 22, 2005 02:22 AM

Hi pls try this method also.I added a event handler to the DataGridColumnStyle.WidthChanged. and reset the width to prefered value. refer the attached sample for more details >tried the code for preventing column resize and it does not work.still able to grab the column in the column header and resize the datagrid. >am i missing something? > >5.44 How can I prevent my user from sizing columns in my datagrid? > >You can do this by subclassing your grid and overriding OnMouseMove, and not calling the baseclass if the point is on the columnsizing border. > >[C#] > >public class MyDataGrid : DataGrid > >{ > > protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e) > > { > > DataGrid.HitTestInfo hti = this.HitTest(new Point(e.X, e.Y)); > > if(hti.Type == DataGrid.HitTestType.ColumnResize) > > { > > return; //no baseclass call > > } > > base.OnMouseMove(e); > > } > >} > > >

datagrid3.zip

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.

;