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.

How to prevent user to change column widths ?

Thread ID:

Created:

Updated:

Platform:

Replies:

90773 Oct 16,2009 08:30 AM Dec 21,2009 01:48 PM WPF 6
loading
Tags: GridControl
Jean-Marc DUHEN
Asked On October 16, 2009 08:30 AM

Hi,

How to prevent user to change column widths ?

I cannot find the relevant property to do it.

I am using the GridControl.

Thanks for your help.

Br,

Jean-Marc

Clay Burch [Syncfusion]
Replied On October 16, 2009 08:51 AM

One way you can do it is the subscribe to this event:

gridControl1.ResizingColumns += new GridResizingColumnsEventHandler(grid_ResizingColumns);


Then in the handler, use code like:

void grid_ResizingColumns(object sender, GridResizingColumnsEventArgs args)
{
args.AllowResize = false;
}

Jean-Marc DUHEN
Replied On October 16, 2009 09:17 AM

Thank you,

it is working perfectly.

Br,

Jean-Marc

Rafael Huapaya
Replied On October 19, 2009 12:56 PM




Ganesan K [Syncfusion]
Replied On October 21, 2009 01:00 AM


Thanks for your feedbacks.

Thanks
Ganesan

Ezequiel Reyno
Replied On December 18, 2009 08:54 AM

Hi,

I need know how I can give to a column a minWidth? I need allow a resize but I need stop them when is equal or minor than some value.

I make this but doesn't work because when I put false in the property AllowResize I can't resize this column anymore.

Private Sub grid_ResizingColumns(ByVal sender As Object, ByVal args As Syncfusion.Windows.Controls.Grid.GridResizingColumnsEventArgs) Handles grid.ResizingColumns
If args.Width < 90 Then
args.AllowRisize = False
End If
End Sub

thanks
Ezequiel

Ganesan K [Syncfusion]
Replied On December 21, 2009 01:48 PM

Hi Ezequiel,

Thanks for using Syncfusion products.

For this you need to listen to the ResizingColumns event as follows

this.dataGrid.Model.Grid.ResizingColumns += new GridResizingColumnsEventHandler(Grid_ResizingColumns);

double minColumnWidth = 90;
void Grid_ResizingColumns(object sender, GridResizingColumnsEventArgs args)
{
switch (args.Reason)
{
case GridResizeCellsReason.MouseMove:
if (args.Width < minColumnWidth)
args.AllowResize = false;
break;
case GridResizeCellsReason.MouseUp:
{
GridControlBase grid = sender as GridControlBase;
grid.Model.ColumnWidths[args.Columns.Left] = Math.Max(args.Width, minColumnWidth);
args.Handled = true;
args.AllowResize = false; //handled directly... grid does not have to do anything
}
break;
default:
break;
}
}

Please let us know if you need any more details.

Thanks
Ganesan

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.

;