回复 9楼keaitutu的帖子
您好,实现的思路是在SelectionChanged中判断单元格的类型,然后记录下来位置,离开的时候,再将颜色清除。
- private int x, y;
- public Form5()
- {
- InitializeComponent();
- this.fpSpread1.SelectionChanged += new FarPoint.Win.Spread.SelectionChangedEventHandler(fpSpread1_SelectionChanged);
- x = 0;
- y = 0;
- }
- void fpSpread1_SelectionChanged(object sender, FarPoint.Win.Spread.SelectionChangedEventArgs e)
- {
- FarPoint.Win.Spread.Model.CellRange cr;
- cr = e.View.Sheets[0].GetSelection(0);
- this.fpSpread1.ActiveSheet.Cells[x, y].BackColor = Color.White;
- if (this.fpSpread1.ActiveSheet.Cells[cr.Row, cr.Column].Locked)
- {
- this.fpSpread1.ActiveSheet.Cells[cr.Row, cr.Column].BackColor = Color.Red;
- x = cr.Row;
- y = cr.Column;
- }
- }
复制代码
需要指出的是,以上实现的方法有一些边界条件没有判断,需要根据实际情况进行处理。 |