一个窗体里有两个spread,分别为fpspread1,fpspread2,在点在任一个里点右键,右键菜单事件怎么判断是点的是fpspread1,还是fpspread2?
private void fpSpread1_MouseDown1(object sender, MouseEventArgs e)
{
//如何判断在哪个fp点的右键????
//右键,弹出右键菜单
if (e.Button == MouseButtons.Right)
{
if (fpSpread1.ActiveSheet != null)
{
SpreadView spreadView = fpSpread1.GetRootWorkbook();
if (spreadView != null)
{
FpSpreadModel.CellRange cellRange = spreadView.GetCellFromPixel(e.X, e.Y);
FpSpreadModel.CellRange[] oldRanges = fpSpread1.ActiveSheet.GetSelections();
bool skip = false;
if (oldRanges != null)
{
foreach (FpSpreadModel.CellRange cr in oldRanges)
{
if (cr.Contains(cellRange.Row, cellRange.Column))
{
skip = true;
break;
}
}
}
if (cellRange != null && !skip)
{
FpSpreadModel.CellRange cellRange1 = new FarPoint.Win.Spread.Model.CellRange(-1, -1, -1, -1);
if (cellRange == cellRange1)
{
if (cellRange.Row != -1)
{
fpSpread1.ActiveSheet.SetActiveCell(oldRanges[0].Row, 0);
}
else if (cellRange.Column != -1)
{
fpSpread1.ActiveSheet.SetActiveCell(0, oldRanges[0].Column);
}
}
else
{
fpSpread1.ActiveSheet.SetActiveCell(cellRange.Row, cellRange.Column);
}
}
}
//弹出右键菜单
contextMenuStrip1.Show(fpSpread1, e.X, e.Y);
}
}
} |
|