/// <summary> /// GridView数据项拖动管理 /// </summary> /// <param name="gvSource">拖动的源GridView</param> /// <param name="gvTarget">拖动的目标GridView</param> /// <param name="callBack">当拖放完成后的回调函数,第一个参数是拖动的源数据RowIndex,第二个参数是目标RowIndex</param> public GridViewMutilRowDragHelper(GridView gvSource, GridView gvTarget, Action <int, int, int> callBack) { var fieldName = "dragColumnField"; if (!gvSource.Columns.Select(x => x.FieldName).Contains(fieldName)) { if (gvSource is BandedGridView bgv) { DragColumn = new BandedGridColumn(); var band = new GridBand(); band.OptionsBand.AllowMove = false; band.OptionsBand.AllowSize = false; band.OptionsBand.FixedWidth = true; band.Visible = true; band.Width = 20; band.Fixed = FixedStyle.Left; bgv.Bands.Insert(0, band); band.Columns.Add(DragColumn as BandedGridColumn); gvSource.Columns.Add(DragColumn); } else { DragColumn = new GridColumn(); DragColumn.Fixed = FixedStyle.Left; gvSource.Columns.Insert(0, DragColumn); } DragColumn.Width = 20; DragColumn.FieldName = fieldName; DragColumn.Visible = true; DragColumn.VisibleIndex = 0; DragColumn.OptionsColumn.AllowSize = false; DragColumn.OptionsColumn.AllowEdit = false; DragColumn.OptionsColumn.ShowCaption = false; DragColumn.OptionsColumn.FixedWidth = true; DragColumn.OptionsColumn.AllowMove = false; } else { DragColumn = gvSource.Columns.FirstOrDefault(x => x.FieldName == fieldName); } this._gcSource = gvSource.GridControl; this._gvSource = gvSource; this._gvTarget = gvTarget; this._gcTarget = gvTarget.GridControl; this._callBack = callBack; this._gvSource.SelectionChanged += GvSrc_SelectionChanged; this._imgHelper = new DragImageHelper(gvSource); this._timer = new Timer(); _timer.Interval = 200; _timer.Enabled = true; _timer.Tick += _timer_Tick; AllowDrop = true; AllowAutoScroll = true; }
/// <summary> /// GridView数据项拖动管理 /// </summary> /// <param name="gvSource">拖动的源GridView</param> /// <param name="gvTarget">拖动的目标GridView</param> /// <param name="callBack">当拖放完成后的回调函数,第一个参数是拖动的源数据RowIndex,第二个参数是目标RowIndex</param> public GridViewDragDropHelper(GridView gvSource, GridView gvTarget, Action <int, int> callBack) { this._gcSource = gvSource.GridControl; this._gvSource = gvSource; this._gvTarget = gvTarget; this._gcTarget = gvTarget.GridControl; this._callBack = callBack; this._imgHelper = new DragImageHelper(gvSource); this._timer = new Timer(); _timer.Interval = 200; _timer.Enabled = true; _timer.Tick += _timer_Tick; AllowDrop = true; }