问题描述:如题
问题解答:Spread 提供MouseDown 事件用于获取鼠标点击事件,在事件中可以通过HitTestInformation 类获取当前操作的单元格。
关键代码:
- private void Form1_Load(object sender, EventArgs e)
- {
- this.fpSpread1.Sheets[0].FrozenRowCount = 1;
- this.fpSpread1.MouseDown += newMouseEventHandler(fpSpread1_MouseDown);
- }
- private void fpSpread1_MouseDown(object sender, MouseEventArgs e)
- {
- //获取当前鼠标点击单元格信息
- HitTestInformationhtinfo = this.fpSpread1.HitTest(e.X, e.Y);
- int curRow = htinfo.ViewportInfo.Row;
- //判断是否点击在冻结行
- if (e.Button == System.Windows.Forms.MouseButtons.Right && curRow == 0)
- {
- FarPoint.Win.Spread.HitTestInformation hitTest = this.fpSpread1.HitTest(e.X, e.Y);
- int row = hitTest.ViewportInfo.Row; int col = hitTest.ViewportInfo.Column;
- this.fpSpread1.Sheets[0].SetActiveCell(row, col);
- }
- }
复制代码
示例下载:点击下载 |
|