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 and Drop leaving data

Thread ID:

Created:

Updated:

Platform:

Replies:

25869 Mar 8,2005 06:03 PM Apr 19,2005 09:17 AM Windows Forms 39
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 8, 2005 06:03 PM

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?

Administrator [Syncfusion]
Replied On March 8, 2005 06:20 PM

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?

Administrator [Syncfusion]
Replied On March 9, 2005 02:11 PM

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?

Administrator [Syncfusion]
Replied On March 9, 2005 02:13 PM

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

Administrator [Syncfusion]
Replied On March 10, 2005 07:16 AM

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.

Administrator [Syncfusion]
Replied On March 10, 2005 09:33 AM

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?

Administrator [Syncfusion]
Replied On March 10, 2005 02:02 PM

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?

Administrator [Syncfusion]
Replied On March 10, 2005 03:34 PM

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?

Administrator [Syncfusion]
Replied On March 16, 2005 03:56 PM

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.

Administrator [Syncfusion]
Replied On March 16, 2005 09:48 PM

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

Administrator [Syncfusion]
Replied On March 17, 2005 02:41 PM

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

Administrator [Syncfusion]
Replied On March 17, 2005 03:33 PM

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.

Administrator [Syncfusion]
Replied On March 28, 2005 12:37 PM

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

Administrator [Syncfusion]
Replied On March 28, 2005 01:49 PM

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.

Administrator [Syncfusion]
Replied On March 28, 2005 02:44 PM

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

Administrator [Syncfusion]
Replied On March 28, 2005 03:45 PM

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

Administrator [Syncfusion]
Replied On April 4, 2005 03:02 PM

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

Administrator [Syncfusion]
Replied On April 4, 2005 06:36 PM

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

Administrator [Syncfusion]
Replied On April 7, 2005 12:04 PM

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.

Administrator [Syncfusion]
Replied On April 7, 2005 12:53 PM

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.

Administrator [Syncfusion]
Replied On April 7, 2005 03:58 PM

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.

Administrator [Syncfusion]
Replied On April 7, 2005 07:57 PM

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.

Administrator [Syncfusion]
Replied On April 8, 2005 11:09 AM

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

Administrator [Syncfusion]
Replied On April 11, 2005 03:18 PM

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

Administrator [Syncfusion]
Replied On April 11, 2005 03:28 PM

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.

Administrator [Syncfusion]
Replied On April 11, 2005 03:34 PM

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

Administrator [Syncfusion]
Replied On April 12, 2005 06:06 PM

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

Administrator [Syncfusion]
Replied On April 13, 2005 09:30 AM

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

Administrator [Syncfusion]
Replied On April 13, 2005 09:56 AM

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

Administrator [Syncfusion]
Replied On April 13, 2005 10:23 AM

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!

Administrator [Syncfusion]
Replied On April 13, 2005 10:34 AM

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.

Administrator [Syncfusion]
Replied On April 15, 2005 10:55 AM

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

Administrator [Syncfusion]
Replied On April 15, 2005 12:35 PM

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

Administrator [Syncfusion]
Replied On April 15, 2005 01:15 PM

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?

Administrator [Syncfusion]
Replied On April 15, 2005 01:22 PM

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

Administrator [Syncfusion]
Replied On April 15, 2005 02:23 PM

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!

Administrator [Syncfusion]
Replied On April 15, 2005 07:24 PM

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

Administrator [Syncfusion]
Replied On April 18, 2005 12:32 PM

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!

Administrator [Syncfusion]
Replied On April 18, 2005 01:25 PM

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

Administrator [Syncfusion]
Replied On April 19, 2005 09:17 AM

Thanks, that took care of it perfectly!

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.

;