void ProcessDragDrop(VGridControl target, DragEventArgs e) { DragInfo dragInfo = (DragInfo)e.Data.GetData(typeof(DragInfo)); VGridControl source = dragInfo.Grid; DataItem item = (DataItem)dragInfo.Data; if (item == null || source == null || target == null) { return; } VGridHitInfo dropHitInfo = target.CalcHitInfo(target.PointToClient(new Point(e.X, e.Y))); int targetRecordIndex = GetRecordIndex(dropHitInfo); RemoveRecord(source, item); AddRecord(target, item, targetRecordIndex); source.RefreshDataSource(); target.RefreshDataSource(); }
private void OnCustomDrawRowHeaderCell(object sender, CustomDrawRowHeaderCellEventArgs e) { Point hitPoint = MousePosition; //if (!(e.Row is CategoryRow)) return; VGridControl grid = (VGridControl)sender; VGridHitInfo hitInfo = ((VGridControl)sender).CalcHitInfo(grid.PointToClient(hitPoint)); if (hitInfo.Row != e.Row) { return; } BaseRowViewInfo rowInfo = null; foreach (BaseRowViewInfo info in grid.ViewInfo.RowsViewInfo) { if (info is CategoryRowViewInfo) { continue; } rowInfo = info; break; } if (rowInfo == null) { return; } RowValueInfo valueInfo = null; foreach (RowValueInfo info in rowInfo.ValuesInfo) { if (info.Bounds.X < hitInfo.PtMouse.X && info.Bounds.Right > hitInfo.PtMouse.X) { valueInfo = info; break; } } if (valueInfo == null) { return; } e.Handled = true; e.Appearance.DrawBackground(e.Cache, e.Bounds); e.Appearance.DrawString(e.Cache, e.Caption, e.CaptionRect); if (e.ImageIndex > 0) { ImageCollection.DrawImageListImage(e.Cache, e.Row.Properties.Images, e.ImageIndex, e.ImageRect); } if (e.Focused) { XPaint.Graphics.DrawFocusRectangle(e.Graphics, e.FocusRect, e.Appearance.ForeColor, e.Appearance.BackColor); } Rectangle hotTrackRect = new Rectangle(valueInfo.Bounds.X, e.Bounds.Y, valueInfo.Bounds.Width, e.Bounds.Height); hotTrackRect.Inflate(-1, -1); e.Graphics.FillRectangle(Brushes.AliceBlue, hotTrackRect); e.Graphics.DrawRectangle(Pens.Blue, hotTrackRect); }