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.

Drag functionality

Thread ID:

Created:

Updated:

Platform:

Replies:

9644 Jan 5,2004 01:58 PM Jan 7,2004 09:33 AM Windows Forms 17
loading
Tags: GridControl
Vineet
Asked On January 5, 2004 01:58 PM

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.

Administrator [Syncfusion]
Replied On January 5, 2004 03:10 PM

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;
	}
}

Vineet
Replied On January 5, 2004 03:33 PM

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;
>	}
>}
>

Administrator [Syncfusion]
Replied On January 5, 2004 06:02 PM

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

Vineet
Replied On January 6, 2004 09:17 AM

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!!!

Vineet
Replied On January 6, 2004 09:32 AM

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

Administrator [Syncfusion]
Replied On January 6, 2004 09:49 AM

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?

Vineet
Replied On January 6, 2004 11:12 AM

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.

Administrator [Syncfusion]
Replied On January 6, 2004 11:53 AM

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.

Administrator [Syncfusion]
Replied On January 6, 2004 12:07 PM

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

Administrator [Syncfusion]
Replied On January 6, 2004 12:22 PM

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);

Administrator [Syncfusion]
Replied On January 6, 2004 01:01 PM

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

Administrator [Syncfusion]
Replied On January 6, 2004 03:20 PM

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.

Administrator [Syncfusion]
Replied On January 6, 2004 03:45 PM

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

Administrator [Syncfusion]
Replied On January 6, 2004 04:01 PM

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

Administrator [Syncfusion]
Replied On January 6, 2004 05:11 PM

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

Administrator [Syncfusion]
Replied On January 7, 2004 07:32 AM

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

Administrator [Syncfusion]
Replied On January 7, 2004 09:33 AM

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

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.

;