Hi, One of my grid (and not the others) fire twice the dragdrop event, ofcourse this isn't wanted so a patched up with a boolean (bDragging) but I was wondering how this could happen.
Here is the code:
private void ugvGroupageFiles_DragDrop(object sender, DragEventArgs e) { if (bDragging) { try { // Get the position on the grid where the dragged row(s) are to be dropped. //get the grid coordinates of the row (the drop zone) UIElement uieOver = ugvGroupageFiles.DisplayLayout.UIElement.ElementFromPoint(ugvGroupageFiles.PointToClient(new Point(e.X, e.Y))); //get the row that is the drop zone/or where the dragged row is to be dropped UltraGridRow ugrOver = uieOver.GetContext(typeof(UltraGridRow), true) as UltraGridRow; if (ugrOver != null && !ugrOver.IsGroupByRow) { Object objItem = new Object(); String strText = String.Empty; char SplitChar = ','; objItem = e.Data.GetData(DataFormats.Text);//Store the data being dragged in an object string[] StrObject = objItem.ToString().Split(SplitChar); // Examine the different drop information and set the appropriate information switch (StrObject[0]) { case "Shipment Movement-2003015-FromGroupageFile": ...
case "Shipment Movement-2003015": clsNavMessage NavMessNewSM = ...
//do some stuff break; default: e.Effect = DragDropEffects.None; break; } } e.Effect = DragDropEffects.None; bDragging = false; LoadData(false); } catch (Exception ex) { frmException ExceptForm = new frmException("Error", ex); ExceptForm.Show(); } } }
private void ugvGroupageFiles_DragEnter(object sender, DragEventArgs e) { bDragging = true; e.Effect = DragDropEffects.Copy; }
Hi,
The Drag events aren't implemented by the grid itself. These events are on Control, so the grid inherits them like all controls do, since all controls derive from the Control class.
So this probably isn't specific to the grid, it must be some more general issue.
I'm not sure why the event would fire twice. Maybe you are hooking it twice?