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

Drag functionality

I am using syncfusion datagrid. In my datagrid I am able to select a particular cell and when I drag it somwhere it leaves that column blank. I do not want that I should be able to drag the column value.

17 Replies

AD Administrator Syncfusion Team January 5, 2004 08:10 PM UTC

The default OLE D&D behavior is to do a ''Move'' if you just drag a selection. To get the ''Copy'' behavior, your user would hold down the ctl key as the drop is made. To change this default behavior, you could implement your own custom drag functionality and bypass the default implementation in the grid. Or, you can just don''t do the clearing by handling a couple of events. Here is code on how this can be done.
//in formload...
this.gridDataBoundGrid1.AllowDrop = true;
this.gridDataBoundGrid1.DragDrop += new DragEventHandler(this.gridDataBoundGrid1_DragDrop);
this.gridDataBoundGrid1.Model.ClearingCells += new GridClearingCellsEventHandler(grid_ClearingCells);

//the handlers
private bool cancelClearing = false;
private void gridDataBoundGrid1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
	e.Effect = DragDropEffects.Copy;
	cancelClearing = true;
}
private void grid_ClearingCells(object sender, GridClearingCellsEventArgs e)
{
	if(cancelClearing)
	{
		e.Handled = true;
		e.Result = false;
		cancelClearing = false;
	}
}


VI Vineet January 5, 2004 08:33 PM UTC

I do not want even the default Move behaviour i.e when the users selects the value in the particular editable cell, he should not be able to drag that. >The default OLE D&D behavior is to do a ''Move'' if you just drag a selection. To get the ''Copy'' behavior, your user would hold down the ctl key as the drop is made. > >To change this default behavior, you could implement your own custom drag functionality and bypass the default implementation in the grid. > >Or, you can just don''t do the clearing by handling a couple of events. Here is code on how this can be done. > >
>//in formload...
>this.gridDataBoundGrid1.AllowDrop = true;
>this.gridDataBoundGrid1.DragDrop += new DragEventHandler(this.gridDataBoundGrid1_DragDrop);
>this.gridDataBoundGrid1.Model.ClearingCells += new GridClearingCellsEventHandler(grid_ClearingCells);
>
>//the handlers
>private bool cancelClearing = false;
>private void gridDataBoundGrid1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
>{
>	e.Effect = DragDropEffects.Copy;
>	cancelClearing = true;
>}
>private void grid_ClearingCells(object sender, GridClearingCellsEventArgs e)
>{
>	if(cancelClearing)
>	{
>		e.Handled = true;
>		e.Result = false;
>		cancelClearing = false;
>	}
>}
>


AD Administrator Syncfusion Team January 5, 2004 11:02 PM UTC

To turn off the grid supporting OLE DnD, you set a flag in ControllerOptions property. gridControl1.ControllerOptions = GridControllerOptions.All & (~GridControllerOptions.OleDataSource); Here is a link to a KB discussing DnD flags. http://www.syncfusion.com/Support/article.aspx?id=10064


VI Vineet January 6, 2004 02:17 PM UTC

The problem that I am facing is in a GridDataBoundGrid in a particular cell when I select a text and after pressing the left mouse button moves it to the other cell and release the mouse button the text from the original cell gets cleared. It shows the sign of a circle with a line, i.e does not drop it anywhere but clears the value from the original text. I have created a sample application in which I am using GridDataBoundGrid with data table with the default settings there it works fine(i.e does not clear the value from the original cell), is the problem because I am setting some properties??? - Thanks Please help!!!


VI Vineet January 6, 2004 02:32 PM UTC

Moreover the events you mentioned in the code does not get triggered.


AD Administrator Syncfusion Team January 6, 2004 02:49 PM UTC

If a sample works OK, but your applciation does not, then investigationg the differences between the two projects would be be one way to try to spot what is causing this behavior. Does the behavior happen with every cell in your grid, or just some cells? What are the cell types for the problem cells? What grid events are you handling?


VI Vineet January 6, 2004 04:12 PM UTC

NO the problem happens with all the cells. Actaully I am setting some properties which might be causing this undesireable feature. Please send me ur mailid I would send the cs file for ur reference.


AD Administrator Syncfusion Team January 6, 2004 04:53 PM UTC

If you want to submit some file for us to look at, you can attach it here, or you can can create a Direct Trac support incident and attach it to the incident. Getting a sample project that shows the problem would be the quickest way for us to try to help you resolve this problem.


AD Administrator Syncfusion Team January 6, 2004 05:07 PM UTC

LauncherUI_1518.zip Please find the cs file see if it helps, by seeing the proerties set.


AD Administrator Syncfusion Team January 6, 2004 05:22 PM UTC

In your property settings, I did not set where you turn off the ControllerOptions flag that allow DnD. Did you try this flag, and it did not make any difference? gridControl1.ControllerOptions = GridControllerOptions.All & (~GridControllerOptions.OleDataSource);


AD Administrator Syncfusion Team January 6, 2004 06:01 PM UTC

Yes actually I tried that option but it did not help.....


AD Administrator Syncfusion Team January 6, 2004 08:20 PM UTC

I tried one thing I commented all the properties which I am setting for the grid, except PrepareViewStyleInfo event, can you just look into the function called during this event call. Is there some problem in that? - Thanks.


AD Administrator Syncfusion Team January 6, 2004 08:45 PM UTC

If you comment out the PrepareViewStyleInfo. do things work? If so, try moving this PrepareViewStyleInfo code into the grid.Model.QueryCellInfo event.


AD Administrator Syncfusion Team January 6, 2004 09:01 PM UTC

If I comment this function call the cell becomes non editable hence can''t perform the desired operation.


AD Administrator Syncfusion Team January 6, 2004 10:11 PM UTC

Try moving this PrepareViewStyleInfo code into the grid.Model.QueryCellInfo event to see if that has an effect.


AD Administrator Syncfusion Team January 7, 2004 12:32 PM UTC

No effect. Problem still not solved though moved the function call.


AD Administrator Syncfusion Team January 7, 2004 02:33 PM UTC

If you submit a sample project that shows the problem, we can look into it.

Loader.
Live Chat Icon For mobile
Up arrow icon