>另只有得到焦点的单元格才能设置成黄色.
代码如下,在CellEnter的时候设置用户想要的颜色,在CellLeave的时候恢复原来的颜色
- private void Form1_Load(object sender, EventArgs e)
- {
- this.gcMultiRow1.RowCount = 5;
- this.gcMultiRow1.CellEnter += new EventHandler<GrapeCity.Win.MultiRow.CellEventArgs>(gcMultiRow1_CellEnter);
- this.gcMultiRow1.CellLeave += new EventHandler<GrapeCity.Win.MultiRow.CellEventArgs>(gcMultiRow1_CellLeave);
- }
- private Color temp = Color.Empty; //临时的变量用于Cache原来的颜色
- private Color UserColor = Color.Yellow; // 用户期望设置成的颜色
- void gcMultiRow1_CellEnter(object sender, GrapeCity.Win.MultiRow.CellEventArgs e)
- {
- temp = this.gcMultiRow1.CurrentCell.Style.BackColor; //进入Cell的时候把原来的颜色保留
- this.gcMultiRow1.CurrentCell.Style.SelectionBackColor = UserColor;//进入Cell的时候,设置用户想要的颜色
- }
- void gcMultiRow1_CellLeave(object sender, GrapeCity.Win.MultiRow.CellEventArgs e)
- {
- this.gcMultiRow1.CurrentCell.Style.SelectionBackColor = temp; //离开Cell的时候,恢复Cell原来的颜色
- }
复制代码 |