public override bool HandleMouseUp(int x, int y, MouseButtons Button) { bool isDragDone = false;//表示是否处理过拖拽操作 是:返回true 否:返回false if (OwnerDocument.OwnerControl.Cursor == Cursors.VSplit) { if (dragCell != null) { isDragDone = true; //确定鼠标要调整的宽度,为正数则是向右拖拽,为负数则是向左拖拽 int moveWidth = x - dragCell.RealLeft; Debug.WriteLine("●●●●调整的宽度: " + moveWidth); int acol = GetColNum(dragCell); int[] tmpWidth = new int[absoluteWidths.Length]; for (int i = 0; i < absoluteWidths.Length; i++) { if (i == (acol - 1)) { tmpWidth[i] = absoluteWidths[i] + moveWidth; } else if (i == acol) { tmpWidth[i] = absoluteWidths[i] - moveWidth; } else { tmpWidth[i] = absoluteWidths[i]; } } SetWidth(tmpWidth); foreach (TPTextRow row in this) { row.Widths = tmpWidth; } foreach (TPTextCell cell in leftColCells) { if (cell.Width != 0) { cell.Width = cell.Width + moveWidth; } } foreach (TPTextCell cell in rightColCells) { if (cell.Width != 0) { cell.Width = cell.Width - moveWidth; } } Debug.WriteLine("●调整列宽后●"); for (int i = 0; i < absoluteWidths.Length; i++) { Debug.WriteLine("第" + i + "列:" + absoluteWidths[i]); } OwnerDocument.ContentChanged(); OwnerDocument.Refresh(); } } LastMousePosition = new Point(-1, -1); currentCell = null; dragCell = null; leftColCells.Clear(); rightColCells.Clear(); return(isDragDone); }