C1.Win.C1FlexGrid Namespace > C1FlexGridBase Class : MouseEnterCell Event |
'Declaration
<C1DescriptionAttribute("Fires when the mouse enters a cell.")> Public Event MouseEnterCell As RowColEventHandler
'Usage
Dim instance As C1FlexGridBase Dim handler As RowColEventHandler AddHandler instance.MouseEnterCell, handler
[C1Description("Fires when the mouse enters a cell.")] public event RowColEventHandler MouseEnterCell
[C1Description("Fires when the mouse enters a cell.")] public: event RowColEventHandler^ MouseEnterCell
Many applications track mouse movement and react to the cell that is currently under the mouse. This can be done using the System.Windows.Forms.Control.MouseMove event, but that is not very efficient since the event fires many times while the mouse is over the same cell.
The MouseEnterCell event allows you to implement cell tracking efficiently, since it only fires once until the mouse leaves the cell.
void Form1_Load(object sender, EventArgs e) { // create style for tracking cell under the mouse CellStyle cs = _flex.Styles.Add("track"); cs.BackColor = Color.Gold; } void _flex_MouseEnterCell(object sender, RowColEventArgs e) { // apply tracking style when mouse enters the cell _flex.SetCellStyle(e.Row, e.Col, _flex.Styles["track"]); } void _flex_MouseLeaveCell(object sender, RowColEventArgs e) { // remove tracking style when mouse leaves the cell _flex.SetCellStyle(e.Row, e.Col, (CellStyle)null); }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2