protected override void OnSelectionChanged(FarPoint.Win.Spread.SelectionChangedEventArgs e) { int reportColumnRowIndex = ReportColumnRowIndex; CellRange cellRange = e.Range; //清空当前选择的报表列。 reportColumnSelected = null; if (cellRange.IntersectRow(reportColumnRowIndex)) { if (e.Range.Row >= 0 && e.Range.Column >= 0) { if (sheetMain.ActiveRowIndex < reportColumnRowIndex) { sheetMain.AddSelection(cellRange.Row, cellRange.Column, cellRange.RowCount - 1, cellRange.ColumnCount); cellRange = new CellRange(cellRange.Row, cellRange.Column, cellRange.RowCount - 1, cellRange.ColumnCount); } else if (sheetMain.ActiveRowIndex > reportColumnRowIndex) { sheetMain.AddSelection(cellRange.Row + 1, cellRange.Column, cellRange.RowCount - 1, cellRange.ColumnCount); cellRange = new CellRange(cellRange.Row + 1, cellRange.Column, cellRange.RowCount - 1, cellRange.ColumnCount); } } } HeaderSettingCommandStatus commandStatus; this.cellRange = cellRange; if (cellRange.Row < 0) { commandStatus = HeaderSettingCommandStatus.SelectColumn; } else if (cellRange.Column < 0) { commandStatus = HeaderSettingCommandStatus.SelectRow; } else if (cellRange.Row == reportColumnRowIndex) { reportColumnSelected = sheetMain.Cells[cellRange.Row, cellRange.Column].Tag as Column; if (reportColumnSelected != null) { commandStatus = HeaderSettingCommandStatus.SelectReportColumn; } else { commandStatus = HeaderSettingCommandStatus.Null; } } else { commandStatus = HeaderSettingCommandStatus.SelectCell; } this.commandStatus = commandStatus; ManualHeaderSettingCommandStatusChanged(); if (this.commandStatus == HeaderSettingCommandStatus.SelectReportColumn) { if (canEditColumn && reportColumnSelected != null) { if (reportColumnPropertyEditor == null) { reportColumnPropertyEditor = new ReportColumnPropertyEditor(); reportColumnPropertyEditor.HeaderSettingFpSpreadChanged += new HeaderSettingFpSpreadChangedHandle(reportColumnPropertyEditor_HeaderSettingFpSpreadChanged); reportColumnPropertyEditor.Init(); Form parentForm = WindowManager.GetTopParentForm(this); parentForm.AddOwnedForm(reportColumnPropertyEditor); parentForm.SizeChanged += new EventHandler(parentForm_SizeChanged); parentForm.LocationChanged += new EventHandler(parentForm_LocationChanged); } #region 获得Fp在屏幕上的显示区域。 Rectangle screenRectangle = GetScreenRectangle(); //与屏幕区域求交集。 screenRectangle = Rectangle.Intersect(screenRectangle, Screen.PrimaryScreen.Bounds); #endregion #region 获得Cell在屏幕上的显示区域。 Rectangle cellScreenRectangle = GetCellScreenRectangle(cellRange.Row, cellRange.Column); //与Fp区域求交集。 cellScreenRectangle = Rectangle.Intersect(cellScreenRectangle, screenRectangle); #endregion #region 去除RowHeader的宽。 int rowHeaderWidth = (int)sheetMain.RowHeader.Columns[0].Width; screenRectangle = new Rectangle(screenRectangle.X + rowHeaderWidth, screenRectangle.Y, screenRectangle.Width - rowHeaderWidth, screenRectangle.Height); #endregion Point point = cellScreenRectangle.Location; point.Offset(cellScreenRectangle.Size.Width / 2, cellScreenRectangle.Size.Height); reportColumnPropertyEditor.ShowColumnProperty(reportColumnSelected, screenRectangle, point); } } else { HideReportColumnPropertyEditor(); } base.OnSelectionChanged(e); }