Drag and drop with in the same ultragrid..i have tried with this code...but it is not working..can any one give me correct sample code solution with explanation .
private void ultraGrid1_SelectionDrag(object sender, CancelEventArgs e) { ultraGrid1.DoDragDrop(ultraGrid1.Selected.Cells, DragDropEffects.Copy | DragDropEffects.Move); // e.Cancel = true; } private void ultraGrid1_DragOver(object sender, DragEventArgs e) { if (e.Data.GetData(typeof(SelectedCellsCollection)) != null) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; }
private void ultraGrid1_DragDrop(object sender, DragEventArgs e) { int dropIndexRow, dropIndexCol; UIElement uieOver = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(ultraGrid1.PointToClient(new Point(e.X, e.Y))); UltraGridRow ugrOver = uieOver.GetContext(typeof(UltraGridRow), true) as UltraGridRow; UltraGridColumn ugrOverCol = uieOver.GetContext(typeof(UltraGridColumn), true) as UltraGridColumn; if (ugrOver != null) { dropIndexRow = ugrOver.Index; dropIndexCol = ugrOverCol.Index; SelectedCellsCollection SelCells; SelCells = (SelectedCellsCollection)e.Data.GetData(typeof(SelectedCellsCollection)); ultraGrid1.Rows[dropIndexRow].Cells[dropIndexCol].Value = SelCells[0].Value;
} } }
Hello
The sample project can be converted to vb.net?
Hi,
Please let me know if you need my further assistance on this matter.
Thank you for using Infragistics Components.
Hello,
Thank you for contacting Infragistics Support.
You are on the right way. In order to be able to perform drag and drop action over the UltraGrid you need to allow this for your grid. You can do this by setting the AllowDrop property of the grid to true. You may do this in the designer or runtime with code like this:
ultraGrid.AllowDrop = true;
After you allow your grid control to accept data that user drop on it you will need to set SelectTypeCell and CellClickAction properties. For example if you need to drag and drop single cell you may use code like this:
ultraGrid.DisplayLayout.Override.SelectTypeCell = SelectType.SingleAutoDrag;
ultraGrid.DisplayLayout.Override.CellClickAction = CellClickAction.CellSelect;
By setting SelectTypeCell property to SingleAutoDrag you are allowing user to select single cell and to start dragging it. More about this property you may find by following the next link http://help.infragistics.com/Doc/WinForms/current/CLR4.0/?page=Infragistics4.Win.UltraWinGrid.v14.2~Infragistics.Win.UltraWinGrid.UltraGridOverride~SelectTypeCell.html
By setting the CellClickAction to CellSelect force the clicked cell to be selected and ready for dragging instead of enter edit mode for example. More about CellClickAction you may find in the link bellow http://help.infragistics.com/Doc/WinForms/current/CLR4.0/?page=Infragistics4.Win.UltraWinGrid.v14.2~Infragistics.Win.UltraWinGrid.UltraGridOverride~CellClickAction.html
Please find attached a sample solution implementing this approach.
Please let me know if this is what you are looking for or if I am missing something.