// handle user dragging a cell to a new position void _ddMgr_DragDrop(object source, DragDropEventArgs e) { if (_dragViewObject != null) { // get target cell var ht = _flex.HitTest(e.GetPosition(_flex)); if (ht.CellType == CellType.Cell && ht.Row > -1 && ht.Column > -1) { // move object to target cell var oldRange = new CellRange(e.DragSource); _flex[oldRange.Row, oldRange.Column] = null; _flex[ht.Row, ht.Column] = _dragViewObject.DataObject; // and move the selection _flex.Select(ht.Row, ht.Column); _dragViewObject = null; } } }
public override void CreateCellContent(C1FlexGrid grid, Border bdr, CellRange range) { // get the data object stored in the unbound grid var obj = grid[range.Row, range.Column] as MyDataObject; if (obj != null) { // create a custom view object var e = new MyViewObject(grid, obj); // assign it to the cell bdr.Child = e; // register cell border as a drag source _ddMgr.RegisterDragSource(bdr, DragDropEffect.Move, ModifierKeys.None); } else { base.CreateCellContent(grid, bdr, range); } }
private void DdMgr_DragStart(object source, DragDropEventArgs e) { var bdr = e.DragSource as Border; _dragViewObject = bdr.Child as MyViewObject; }