private void DrawColumnDrag(PaintEventArgs e)
        {
            if (_draggingCell != null)
            {
                var text    = "";
                int offsetX = 0;
                int offsetY = 0;

                QueryItemText?.Invoke(_draggingCell.RowIndex.Value, _columns.IndexOf(_draggingCell.Column), out text);
                QueryItemTextAdvanced?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, out text, ref offsetX, ref offsetY);

                Color bgColor = ColumnHeaderBackgroundColor;
                QueryItemBkColor?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, ref bgColor);

                int x1 = _currentX.Value - (_draggingCell.Column.Width.Value / 2);
                int y1 = _currentY.Value - (CellHeight / 2);
                int x2 = x1 + _draggingCell.Column.Width.Value;
                int y2 = y1 + CellHeight;

                sBrush = new SolidBrush(bgColor);
                e.Graphics.FillRectangle(sBrush, x1, y1, x2 - x1, y2 - y1);
                sBrush = new SolidBrush(ColumnHeaderFontColor);
                e.Graphics.DrawString(text, ColumnHeaderFont, sBrush, (PointF)(new Point(x1 + CellWidthPadding + offsetX, y1 + CellHeightPadding + offsetY)));
            }
        }
        private void DrawData(PaintEventArgs e, List <ListColumn> visibleColumns)
        {
            // Prevent exceptions with small windows
            if (visibleColumns.Count == 0)
            {
                return;
            }

            if (QueryItemText != null || QueryItemTextAdvanced != null)
            {
                int startRow = FirstVisibleRow;
                int range    = Math.Min(LastVisibleRow, ItemCount - 1) - startRow + 1;

                sBrush = new SolidBrush(CellFontColor);

                int xPadding = CellWidthPadding + 1 - _hBar.Value;
                for (int i = 0, f = 0; f < range; i++, f++)                 // Vertical
                {
                    //f += _lagFrames[i];
                    int LastVisible = LastVisibleColumnIndex;
                    for (int j = FirstVisibleColumn; j <= LastVisible; j++)                     // Horizontal
                    {
                        ListColumn col = visibleColumns[j];

                        string text       = "";
                        int    strOffsetX = 0;
                        int    strOffsetY = 0;
                        Point  point      = new Point(col.Left.Value + xPadding, RowsToPixels(i) + CellHeightPadding);

                        Bitmap image         = null;
                        int    bitmapOffsetX = 0;
                        int    bitmapOffsetY = 0;

                        QueryItemIcon?.Invoke(f + startRow, visibleColumns[j], ref image, ref bitmapOffsetX, ref bitmapOffsetY);

                        if (image != null)
                        {
                            e.Graphics.DrawImage(image, new Point(point.X + bitmapOffsetX, point.Y + bitmapOffsetY + CellHeightPadding));
                        }

                        QueryItemText?.Invoke(f + startRow, _columns.IndexOf(visibleColumns[j]), out text);
                        QueryItemTextAdvanced?.Invoke(f + startRow, visibleColumns[j], out text, ref strOffsetX, ref strOffsetY);

                        bool rePrep = false;
                        if (_selectedItems.Contains(new Cell {
                            Column = visibleColumns[j], RowIndex = f + startRow
                        }))
                        {
                            sBrush = new SolidBrush(InvertColor(CellBackgroundHighlightColor));
                            rePrep = true;
                        }

                        if (!string.IsNullOrWhiteSpace(text))
                        {
                            ResizeTextToFit(ref text, col.Width.Value, CellFont);
                            e.Graphics.DrawString(text, CellFont, sBrush, (PointF)(new Point(point.X + strOffsetX, point.Y + strOffsetY)));
                        }

                        if (rePrep)
                        {
                            sBrush = new SolidBrush(CellFontColor);
                        }
                    }
                }
            }
        }