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. Image for the cookie policy date

Restrict Drag For Individual Columns

Hi All, I am using a Grouping Grid[Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl], my requirement is to freeze first few columns depending upon the user choice. I am able to freeze cols at run time, but here one condition is the freezed columns should not be allowed to drag or moved. But the remaining columns in the grid should have drag & move facility. Is there any way to set Drag options for each individual columns. Thanks

3 Replies

AD Administrator Syncfusion Team August 20, 2005 03:44 PM UTC

You can try handling the TableControlMouseDown event and conditionally setting the AllowDragCols property there. private void gridGroupingControl1_TableControlMouseDown(object sender, GridTableControlMouseEventArgs e) { int row, col; if(e.TableControl.PointToRowCol(new Point(e.Inner.X, e.Inner.Y), out row, out col)) { GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(row, col); if(style.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell && style.TableCellIdentity.Column.Name == "Col1") { this.gridGroupingControl1.TableOptions.AllowDragColumns = false; } else { this.gridGroupingControl1.TableOptions.AllowDragColumns = true; } } }


VI Vinay August 22, 2005 07:33 AM UTC

This works fine when I try to drag the selected columns[Restricted Columns]. But when I try to drop any other column on the Restricted columns it fails. Here my Requirement For Eq I have 10 columns in my data source & 3 columns need to be freezed. Freezed Col should not be allowed to participate in drag /Drop , also other 7 columns should not be allowed to be droped on the 3 column. Can you provide me some events which will help me to achieve this functionality. Thanks >You can try handling the TableControlMouseDown event and conditionally setting the AllowDragCols property there. > >private void gridGroupingControl1_TableControlMouseDown(object sender, GridTableControlMouseEventArgs e) >{ > int row, col; > if(e.TableControl.PointToRowCol(new Point(e.Inner.X, e.Inner.Y), out row, out col)) > { > GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(row, col); > if(style.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell > && style.TableCellIdentity.Column.Name == "Col1") > { > this.gridGroupingControl1.TableOptions.AllowDragColumns = false; > } > else > { > this.gridGroupingControl1.TableOptions.AllowDragColumns = true; > } > } >} >


AD Administrator Syncfusion Team August 22, 2005 04:40 PM UTC

Try handling the TableControlQueryAllowDragColumn event.
private void gridGroupingControl1_TableControlQueryAllowDragColumn(object sender, GridQueryAllowDragColumnEventArgs e)
{
	if (e.InsertBeforeColumn != null 
		&& e.TableControl.TableDescriptor.VisibleColumns.IndexOf(e.InsertBeforeColumn) < 3)
	{
		e.AllowDrag = false;
	}
}

Loader.
Live Chat Icon For mobile
Up arrow icon