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.

Disabling ability to to select columns by Clicking one, then dragging to another

Thread ID:

Created:

Updated:

Platform:

Replies:

50159 Oct 6,2006 03:45 PM Jan 23,2009 05:55 AM Windows Forms 5
loading
Tags: GridControl
Michael Scott
Asked On October 6, 2006 03:45 PM

The following lines :

this.gridCtl.AllowDragSelectedCols = false;
this.gridCtl.AllowDragSelectedRows = false;

aren''''t preventing the user from MouseDown''ing on one column (like C), then dragging to another column (like F) to select those columns (C..F). It''s a standard gridctl - does it need to be a specific type of Grid Ctl?

If I can''''t disable that, how to I take advantage of that, and register which colums (or rows) were selected when I MouseUp?

I still didn''''t understand the difference between grid.Model.Selections.* and regular grid.Selections.* (like grid.Model.Selections.Add vs. grid.Selections.Add).

Nor am I clear what the difference between Selections.Add and Selections.SelectRange are. I *think* you were previously trying to say that Add just adds a range, where SelectRange lets you either Add or Delete a range. Did I understand you correctly?

Michael

Administrator [Syncfusion]
Replied On October 9, 2006 11:14 PM

Hi Michael,

Issue 1: column selection and dragging.

If you want to prevent the column selection when clicked on the columnheader, you can set the AllowSelection property of the grid. Below is a code snippet

//to prevent the Column selection..
this.gridDataBoundGrid1.AllowSelection = GridSelectionFlags.Any ^ GridSelectionFlags.Column;

//to prevent the selected column dragging
this.gridDataBoundGrid1.AllowDragSelectedCols = false;

this.gridDataBoundGrid1.ControllerOptions = GridControllerOptions.All ^ GridControllerOptions.DragSelectRowOrColumn;

Issue 2 : difference between Selections.Add and Selections.SelectRange

Did I understand you correctly?
>>>>>>>>>>

Yes. The Selections.Add method only adds a GridRangeInfo to the list of selected ranges. But you can use the Selections.SelectedRange method to add or remove a GridRangeInfo from the list of selected ranges.

Let me know if this helps.

Best Regards,
Haneef

Sameer Khan
Replied On January 16, 2009 11:08 AM

How would one prevent a subset of the columns from eing dragged around?

I want to keep the first n columns static; but allow the rest of the columns from being rearranged.

This means; that not only do I want the first n columns to not move; I dont want other columns to be dropped in the first n set.

-S

>Hi Michael,

Issue 1: column selection and dragging.

If you want to prevent the column selection when clicked on the columnheader, you can set the AllowSelection property of the grid. Below is a code snippet

//to prevent the Column selection..
this.gridDataBoundGrid1.AllowSelection = GridSelectionFlags.Any ^ GridSelectionFlags.Column;

//to prevent the selected column dragging
this.gridDataBoundGrid1.AllowDragSelectedCols = false;

this.gridDataBoundGrid1.ControllerOptions = GridControllerOptions.All ^ GridControllerOptions.DragSelectRowOrColumn;

Issue 2 : difference between Selections.Add and Selections.SelectRange

Did I understand you correctly?
>>>>>>>>>>

Yes. The Selections.Add method only adds a GridRangeInfo to the list of selected ranges. But you can use the Selections.SelectedRange method to add or remove a GridRangeInfo from the list of selected ranges.

Let me know if this helps.

Best Regards,
Haneef


Rajadurai C [Syncfusion]
Replied On January 17, 2009 03:52 AM

Hi Sameer,

Thanks for your interest in Syncfusion products.

To handle column header dragging the ControllerOptions property has to be set to DragColumnHeader.

this.gridControl1.ControllerOptions = GridControllerOptions.DragColumnHeader;


To prevent a column from being dragged, QueryAllowDragColumnHeader event has to be handled.

this.gridControl1.QueryAllowDragColumnHeader += new GridQueryDragColumnHeaderEventHandler(gridControl1_QueryAllowDragColumnHeader);

void gridControl1_QueryAllowDragColumnHeader(object sender, GridQueryDragColumnHeaderEventArgs e)
{
if (e.Column == 3)
e.AllowDrag = false;
}


To prevent a column from being dropped with other column, ColsMoving event has to be handled.

private void gridControl1_ColsMoving(object sender, Syncfusion.Windows.Forms.Grid.GridRangeMovingEventArgs e)
{
if(e.Target == 3)
{
e.Cancel = true;
this.gridControl1.Cols.MoveRange(e.From,1,e.From);
}
}


Please refer to the following sample that implements this.
http://websamples.syncfusion.com//samples/Grid.Windows/F50159.zip

Regards,
Rajadurai


Sameer Khan
Replied On January 20, 2009 02:54 PM

QueryAllowDragColumn works fine; so I am now able to supress the move.


However; TableModel.ColsMoved is never called
I have set the following options:

_grid.TableModel.Options.ControllerOptions = GridControllerOptions.DragColumnHeader ^ GridControllerOptions.DragSelectRowOrColumn;

Am I missing something?


Note I am using the grid grouping control.

>Hi Sameer,

Thanks for your interest in Syncfusion products.

To handle column header dragging the ControllerOptions property has to be set to DragColumnHeader.

this.gridControl1.ControllerOptions = GridControllerOptions.DragColumnHeader;


To prevent a column from being dragged, QueryAllowDragColumnHeader event has to be handled.

this.gridControl1.QueryAllowDragColumnHeader += new GridQueryDragColumnHeaderEventHandler(gridControl1_QueryAllowDragColumnHeader);

void gridControl1_QueryAllowDragColumnHeader(object sender, GridQueryDragColumnHeaderEventArgs e)
{
if (e.Column == 3)
e.AllowDrag = false;
}


To prevent a column from being dropped with other column, ColsMoving event has to be handled.

private void gridControl1_ColsMoving(object sender, Syncfusion.Windows.Forms.Grid.GridRangeMovingEventArgs e)
{
if(e.Target == 3)
{
e.Cancel = true;
this.gridControl1.Cols.MoveRange(e.From,1,e.From);
}
}


Please refer to the following sample that implements this.
http://websamples.syncfusion.com//samples/Grid.Windows/F50159.zip

Regards,
Rajadurai




Rajadurai C [Syncfusion]
Replied On January 23, 2009 05:55 AM

Hi Sameer,

Thanks for your update.

Please try handling TableDescriptor.Columns.Changed/Changing events as these get fired when columns are moved in gridgroupingcontrol. Here is a sample code:

this.gridGroupingControl1.TableDescriptor.Columns.Changed += new Syncfusion.Collections.ListPropertyChangedEventHandler(Columns_Changed);
void Columns_Changed(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e)
{
if (e.Action == ListPropertyChangedType.Move)
MessageBox.Show("Moved");
}


Regards,
Rajadurai


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.

;