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
close icon

Drag and Drop leaving data

We are trying to use the built in drag and drop ability of the DBDG but on a move sometimes the data still remains at the source, yet the data is copied to the new location. The grid is not consistant either, sometimes it leaves the entire selection, othertimes just part of it is left in place. Lastly there are times when a single row is moved and suddenly there will be two identical rows where the data was dropped. Is there something up with the grid that we didnt enable, or is this usual?

39 Replies

AD Administrator Syncfusion Team March 8, 2005 11:20 PM UTC

Do you see any exceptions being thrown? (Maybe trying to paste some text into a double or something of this nature). Can you tell us how to see this behavior in one of our samples, or can you upload a sample project showing this problem?


AD Administrator Syncfusion Team March 9, 2005 07:11 PM UTC

After trying this for some time we have found that our grid is having problems when dropping data into a row directly above or below the selection. If the user drags the mouse near the border and drops the data, instead of deleting the source cells the grid makes copies in both rows. here is another example of the grid not working, if a user selects data in 1 row, but over 10 columns, then moves to drop the data 3 rows up and 4 to the right, the grid will usually leave the source information, BUT as soon as the selection overlaps the drop columns, the data in the source row will be overwritten by the destinations info. Ie source was 1,2,3,4,5,6,7,8,9,0 destination is up and over by a couple, source row will now look like 1,2,3,4,1,2,3,4,5,6 instead of being all 0''s. I would like to send you the file but the upload page will not open. Is there any email address that I can send this to? >Do you see any exceptions being thrown? (Maybe trying to paste some text into a double or something of this nature). > >Can you tell us how to see this behavior in one of our samples, or can you upload a sample project showing this problem?


AD Administrator Syncfusion Team March 9, 2005 07:13 PM UTC

You can send your sample to support@syuncfusion.com and mention this forum thread in the subject line.


AD Administrator Syncfusion Team March 10, 2005 12:16 PM UTC

Did you get the email with the zip file? >You can send your sample to support@syuncfusion.com and mention this forum thread in the subject line.


AD Administrator Syncfusion Team March 10, 2005 02:33 PM UTC

I did get your sample but have not been able to run it. I swapped out the paths to the mdb file. But when I try to run the code, I get access denied to a SQL server in the ExecuteSQLforDS routine. If I check the connection string in that method, it is trying to hit a server at some ip address and not trying to use the mdb file. Did you try running the sample on a system not connected to your network?


AD Administrator Syncfusion Team March 10, 2005 07:02 PM UTC

Just re-emailed a sample that will work for you. Thanks >I did get your sample but have not been able to run it. > >I swapped out the paths to the mdb file. But when I try to run the code, I get access denied to a SQL server in the ExecuteSQLforDS routine. If I check the connection string in that method, it is trying to hit a server at some ip address and not trying to use the mdb file. > >Did you try running the sample on a system not connected to your network?


AD Administrator Syncfusion Team March 10, 2005 08:34 PM UTC

Try running your application with your debugger set to break on exceptions. I think there are a lot of exceptions being thrown that you might want to try to avoid by judiciously checking indexes and type conversions. These exceptions may be playing a role in the behavior that you are seeing. Can you give me explicit steps to see the exact problem you are having in the sample?


AD Administrator Syncfusion Team March 16, 2005 08:56 PM UTC

Clay, Just sent you an updated version of the broken grid. Ran the program with all exceptions turned on and fixed all errors. In the email message I explain how to get the 3 main problems we are having. If you need I can send video clips showing what is happening.


AD Administrator Syncfusion Team March 17, 2005 02:48 AM UTC

I can see the problem. I will update this thread when I have more information on it. You can avoid it temporarily by deriving the grid and override OnDragDrop and forceing the Effect there. But we probably need ot fix it in our code base.
public class MyGridDataBoundGrid : GridDataBoundGrid
{
	protected override void OnDragDrop(DragEventArgs drgevent)
	{
		base.OnDragDrop (drgevent);
		if((Control.ModifierKeys & Keys.Control) == 0)
			drgevent.Effect = DragDropEffects.Move;
	}
}


AD Administrator Syncfusion Team March 17, 2005 07:41 PM UTC

Is there another style of grid that would work for what I am trying to do? I dont have my heart set on the DBDG, it was the first one I found that would let me set its datasource through code using a data table. Thanks


AD Administrator Syncfusion Team March 17, 2005 08:33 PM UTC

If drop & drop is important for your application, then either GridControl or GridDataBoundGrid would be the first choices. If you want to use a one of these grids bound to a datatable, then GridDataBoundGrid is the simpler choice.


AD Administrator Syncfusion Team March 28, 2005 05:37 PM UTC

I have modified the code you supplied to VB.Net and currently have created a new class file with the following inside: Public Class DataGridOverride Inherits GridDataBoundGrid Protected Overrides Sub OnDragDrop(ByVal drgevent As DragEventArgs) MyBase.OnDragDrop(drgevent) If (Control.ModifierKeys & Keys.Control) = 0 Then drgevent.Effect = DragDropEffects.Move End If End Sub End Class There is a slight problem in that ''GridDataBoundGrid'' and ''OnDragDrop'' are underlined with ''Type GridDataBoundGrid is not defined'' and ''sub onDragDrop cannot be declared ''overrides'' as it does not override a sub in a base class'' Now a friend said to change the inherits line to: "Inherits Syncfusion.Base.Grid.GridDataBoundGrid or whatever the namespace is for the grid." Syncfusion.Windows.Forms.Grid.GridDataBoundGrid was the only thing that I found that seemed to match up. When I used this, but blue lines went away, but the code still did not seem to be firing (I put a debug.writeline statement in there and nothing ever showed up in the console nor did its behavior change) Thanks >I can see the problem. I will update this thread when I have more information on it. > >You can avoid it temporarily by deriving the grid and override OnDragDrop and forceing the Effect there. But we probably need ot fix it in our code base. >
>public class MyGridDataBoundGrid : GridDataBoundGrid
>{
>	protected override void OnDragDrop(DragEventArgs drgevent)
>	{
>		base.OnDragDrop (drgevent);
>		if((Control.ModifierKeys & Keys.Control) == 0)
>			drgevent.Effect = DragDropEffects.Move;
>	}
>}
>


AD Administrator Syncfusion Team March 28, 2005 06:49 PM UTC

The namespace you chose is correct. In order to get your code to use your DataGridOverride on your form instead of the GridDataBoundGrid you are using now, you need to change the code where your GridDataBoundGrid is declared to be DataGridOverride, and also the code where your GridDataBoundGrid is created to DataGridOverride. Nornmally, this means there are two place where you have to change Syncfusion.Windows.Forms.Grid.GridDataBoundGrid into DataGridOverride. These two places are normally in the code generated by the designer if you put the grid on teh form with teh designer. When using a derived control, make sure you build your project before you try to open the form in the designer. Opening teh form in teh designer without building the project means that VS will not be able to find your derived control, and will remove it from teh design surface. But building the project before you popen the form in teh designer (the first time after loading it) will avoid this problem.


AD Administrator Syncfusion Team March 28, 2005 07:44 PM UTC

well Ive made changes to these two lines and the designer recognizes that it is a datagridoverride, but the ondrop is still not firing? Friend WithEvents GridDataBoundGrid1 As DataGridOverride ''Syncfusion.Windows.Forms.Grid.GridDataBoundGrid Me.GridDataBoundGrid1 = New DataGridOverride ''Syncfusion.Windows.Forms.Grid.GridDataBoundGrid


AD Administrator Syncfusion Team March 28, 2005 08:45 PM UTC

In a separate email, I am returning your sample with a derived grid where the OnDragDrop override is being hit for me.


AD Administrator Syncfusion Team April 4, 2005 07:02 PM UTC

Hi Clay, The undesired behavior was still happening in the grid you sent back. I heard that an update will be shipping in a week or so. Do you think there will be any chance that the update may fix this behavior? I am willing to wait for it if that will take care of the problem. Thanks


AD Administrator Syncfusion Team April 4, 2005 10:36 PM UTC

There have been no changes to address this problem for the upcoming release. How can I see the problem in the sample I sent you? If you run the sample in debug with the ouput window visible, do you see the output from the WirteLine in the override shown below? Public Class MyGridDataBoundGrid Inherits Syncfusion.Windows.Forms.Grid.GridDataBoundGrid Protected Overrides Sub OnDragDrop(ByVal drgevent As System.Windows.Forms.DragEventArgs) MyBase.OnDragDrop(drgevent) Console.WriteLine("OnDragDrop") drgevent.Effect = DragDropEffects.Move End Sub End Class


AD Administrator Syncfusion Team April 7, 2005 04:04 PM UTC

The "OnDragDrop" is showing up in the console window when I move the data. But after a drag and drop the source cells reset to their previous values if you enter the cell. For example, in the first row, I put a 1 in say 6 cells. I highlight some these cells, drag and drop them 4 rows straight down. Then if I click back in one of the cells all of the selection’s data is restored (with the exception of the cell that has focus from the drag and drop operation). I double checked and the code is just how you had it: Protected Overrides Sub OnDragDrop(ByVal drgevent As System.Windows.Forms.DragEventArgs) MyBase.OnDragDrop(drgevent) Console.WriteLine("OnDragDrop") drgevent.Effect = DragDropEffects.Move End Sub Also I have just updated to version 3.2.0.0 and the behavior is the same.


AD Administrator Syncfusion Team April 7, 2005 04:53 PM UTC

And you are seeing this behavior in that sample I sent you? I type 1 five times to enter 1 in the first 5 cells of row 1. I then use the mouse to select cells 1 through 4 in that row. I then mousedown and drag at the bottom of cell D1, and drag the 4 cells to row 4 columns 1 to 4. I then click on cell 1,1 and type 5 and press enter. Cell 2 through 4 remain empty for me. Are you seeing any exceptions being thrown in the output window. If you only see the problme in your oce, but not the sample code, then it may have something to do with the fact that the current record has an open edit (pencil in the header cell) when the drag starts. You might try overrideing OnDragEnter in your derived grid, and there call this.Binder.EndEdit before you call the base class. This should save the pending changes at the start of the drag.


AD Administrator Syncfusion Team April 7, 2005 07:58 PM UTC

Yes I am using the sample that you sent back and it is still having problems, but no exceptions are being thrown. By following exactly what you described above the problem did not occur, but if things go a little differently the cells do their reappearing trick. Here is how I get it to break (sorry for the excessive detail on the description here) I start the program and see a grid with the following columns Est, TD, SCH, 4/4, 5, 6,7,8,9, 4/11….. and so on with a date in each col with Sundays being skipped (I will be referring to the columns by their date, not position even through they do line up) Starting in the col with 4/4 I put a 1 in the first row, and do the same for 5,6,7 and 8 Now I highlight these cells starting at 4/4 and ending at 4/8 At this point, 4/4 is a white box, and the other 4 are blue. I begin a DD by clicking on the bottom of 8, and drop the set 3 rows below in the same columns. (So far I think we are 100% the same at this point.) Now after the drop, the cells in the first row, cols 4/4,5,6,7 and 8 are blank with 4/4 still selected and white, and 5,6,7,8 are all still blue. Now if I click in the first row, column 4/4 the selection goes away, but when I click on 4/4 the 4th row the 1’s reappear in row one, columns 5,6,7 and 8 Next Test (reset the grid, fill in the data and perform the move) The cells are still blue after a DD and I click in row 1, column 8, then I click outside the original selection area (say column 8 row 2) and the data will reappear. Now I did notice that this happened a good majority of the time, but not every time. Additionally there were a few times that I had to do the drag and drop, retype the data, and on the second drag and drop operation the problems would show up. During this time, the console did print the “DoDragDrop” text but no other errors with all exceptions set to break in the debugger.


AD Administrator Syncfusion Team April 7, 2005 11:57 PM UTC

I think I followed you steps explicitly more than a dozen times, and the deleted data does not reappear for me. I am using the 3.201.0.0 syncfusion dll''s. In the samaple where you ar seeng this behavior, you are using that mdb file you sent me, correct? If you are using aSQl db or something, that might explain the difference in what we are seeing. Here is something to try. Try setting Me.GridDataBoundGrid1.Binder.DirectSaveCellInfo = True in the form''s constructor after teh call to InitializeComponent() to see if that affects what you are seeing.


AD Administrator Syncfusion Team April 8, 2005 03:09 PM UTC

In the production verion that I am working with, we are connecting to a SQL server, but when I describe these errors, I double check that they are happening on the testing version I sent you running on the mdb file. I tried the line of code and it didnt make any difference. On a lark, I will go and compile and install this on another machine just to make sure it is not something happening just on my computer. In the mean time, could you send the code you have again. Thanks


AD Administrator Syncfusion Team April 11, 2005 07:18 PM UTC

Clay, I got your file and the program is still having data reappear. I have created a video file to show this, but it is around 20 megs. I goes from opening the attachment to the actual problem. If you want, I could cut out any of the ** ones below to save space - they take about 50% of the entire screen time **Open the received attachment and extract it to a pre-selected directory **Open the project **Change the location for the mdb file so the program will compile Run the program and place 1s in a few cells Highlight and drag the cells. Move back into the cells and show the data reappearing. type more info into the cells and repeat Show that the reappearing data does not always happen Get the data to reappear one more time. End. Then I took 2 screen shots of the output showing that there is no errors and only a couple ''ondragdrop'' lines. I am willing to do/try pretty much anything at this point to get this to work. Perhaps there is some setting in the designer I have different, I dont know. But when this code hits my machine, or when I compile it into an executable program it does not behave correctly. Perhaps you could create a setup project in your files, create an install project and if that doesn’t exhibit the behavior on a different machine there you could send it to me and I will try it on a few computers here. Thought I should give you a heads up before sending a 20 meg attachment, and wanted to know if there is an email address other then support@ I should send it to. Thanks again for the help


AD Administrator Syncfusion Team April 11, 2005 07:28 PM UTC

You need to create a direct trac support incident for this problem. I am out of the office this week and do not have any facility for downloading 20 meg files. So, you are saying that you run the exact sample I emailed you, and you see the problem, and this 20 meg movie file shows how to see the problem in that sample. In that case someone at syncfusion should be able to reproduce it following your movie.


AD Administrator Syncfusion Team April 11, 2005 07:34 PM UTC

Thats pretty much the case. I will create a direct track incident right away. Thanks!


AD Administrator Syncfusion Team April 12, 2005 10:06 PM UTC

Justin, I made some more changes to the MyGridDataBoundGrid class. Please try it with those changes. I uploaded the file here: ProjectedSchedule.vb Thanks, Stefan


AD Administrator Syncfusion Team April 13, 2005 01:30 PM UTC

I am unable to download this file, an error occurs saying that: Server Error in ''/Support/user'' Application. This type of page is not served. Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension ''.vb'' may be incorrect. Please review the URL below and make sure that it is spelled correctly. Requested Url: /Support/user/uploads/ProjectedSchedule_133cbab0.vb


AD Administrator Syncfusion Team April 13, 2005 01:56 PM UTC

Try this link. http://www.syncfusion.com/Support/user/uploads/ProjectedSchedule_133cbab0.zip


AD Administrator Syncfusion Team April 13, 2005 02:23 PM UTC

Thanks for the new link clay, and the code appears to be working great! Ive tried to get it to break for a few minutes and its done everything correctly. Its also working in the production code as well. Thanks again!


AD Administrator Syncfusion Team April 13, 2005 02:34 PM UTC

Sorry for the fase positive... I did find a case where the program does not work. If you highlight a group of cells, drag them and release them such that there is an overlap between the original selection and the destination the drop does not work. Ie, select columns 4-8 and drop them in the same row with the drop starting in column 7 then on the drop the source cells will all be blanked out and the destination will do nothing. Another thing I found is if you select cols 4-8 over rows 1-3 and then drop on col 4, row 3 the source is again blanked but row 4 will have 2''s data, and row 5 will have 3''s. in this case just row 3 doesnt get re written.


AD Administrator Syncfusion Team April 15, 2005 02:55 PM UTC

any idea why this new code will delete the data to be copied when dragging to a new location in the same row?


AD Administrator Syncfusion Team April 15, 2005 04:35 PM UTC

Since the claering is done aftewr the drop, if teh regions overlap, the clearing steps on the drop. Try this code in your OnDragDrop to see if it handles all the problems you were seeing.
    Protected Overrides Sub OnDragDrop(ByVal drgevent As System.Windows.Forms.DragEventArgs)
        Binder.EndEdit()
        MyBase.Binder.DirectSaveCellInfo = True
        MyBase.OnDragDrop(drgevent)
        MyBase.Binder.DirectSaveCellInfo = False
        Binder.EndEdit()
    End Sub


AD Administrator Syncfusion Team April 15, 2005 05:15 PM UTC

That actually took care of the problem of dragging in the same row, but the overlap is still being deleting. also, I put a breakpoint on Private Sub m_QueryDragDropMoveClearCells(...) and ran the program again. The cells would move to their new position then this function would fire clearing out the original selection (including any overlap). Could a check with the origal range info and the new position be used to not overwrite the overlapping cells?


AD Administrator Syncfusion Team April 15, 2005 05:22 PM UTC

m_QueryDragDropMoveClearCells should not be hit when using the code I suggested above. (It does not set DragDropEffects.Move value that triggers the hitting of this event.)


AD Administrator Syncfusion Team April 15, 2005 06:23 PM UTC

Thanks Clay, I originally misunderstood what you wanted, and I incorportated the Binder.EndEdit() calls to the existing ondragdrop instead of rewriting the full sub. Its been working pretty good for all the things Ive tried, though I do have one question you might be able to answer. The way I have the grid setup, the first 3 columns are used for some totalling and summary infomation. Is there a way to not allow data to be dropped (or even selected) in just these columns (or the blank space rows as well?) Thanks!


AD Administrator Syncfusion Team April 15, 2005 11:24 PM UTC

You can override OnDragOver and check the potential drop column there, setting e.Effects to None when you do not want to drop.
    Protected Overrides Sub OnDragOver(ByVal e As System.Windows.Forms.DragEventArgs)
        MyBase.OnDragOver(e)

        Dim pt As Point = Me.PointToClient(New Point(e.X, e.Y))
        Dim row, col As Integer
        If (Me.PointToRowCol(pt, row, col)) Then
            If col - m.DragDropData.dndColOffset < 4 Then ''dont drop in 1st 3 cols
                e.Effect = DragDropEffects.None
            End If
        End If
    End Sub


AD Administrator Syncfusion Team April 18, 2005 04:32 PM UTC

The code looks good, there just one problem with it. in the line If col - m.DragDropData.dndColOffset < 4 Then ''''dont drop in 1st 3 cols The m is not defined, I tried substituting e. and me. but neither one worked. Also, I assume this code would be put in the Public Class MyGridDataBoundGrid that we were working with eariler to override the dragdrop event. Thanks!


AD Administrator Syncfusion Team April 18, 2005 05:25 PM UTC

m is the Model, so try substiting the me.Model for m in your derived grid.


AD Administrator Syncfusion Team April 19, 2005 01:17 PM UTC

Thanks, that took care of it perfectly!

Loader.
Live Chat Icon For mobile
Up arrow icon