把 fpSpread2_MouseMove()的代码稍改以下就可以了:
void fpSpread2_MouseMove(object sender, MouseEventArgs e)
{
int rowIndex;
HitTestInformation hti;
ViewportHitTestInformation vi;
hti = fpSpread1.HitTest(e.X, e.Y);
if (hti != null && hti.Type == HitTestType.Viewport)
{
vi = hti.ViewportInfo;
if (vi.Column == 0)
{
rowIndex = vi.Row;
if (fpSpread1.ActiveSheet.Cells[rowIndex, 0].RowSpan > 1)
{
CellRange cellRange = fpSpread1.GetCellFromPixel(0, 0, e.X, e.Y);
rowIndex = cellRange.Row;
}
MessageBox.Show(fpSpread1.ActiveSheet.Cells[rowIndex, 1].Value.ToString());
}
}
} |