'宣言 Public Event MouseEnterCell As RowColEventHandler
public event RowColEventHandler MouseEnterCell
イベント データ
イベント ハンドラが、このイベントに関連するデータを含む、RowColEventArgs 型の引数を受け取りました。次の RowColEventArgs プロパティには、このイベントの固有の情報が記載されます。
プロパティ | 解説 |
---|---|
Cancel | Gets or sets a value indicating whether the operation should be canceled. |
Col | Gets the index of the column that caused the event. |
Row | Gets the index of the row that caused the event. |
解説
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.
使用例
The code below tracks mouse movement and highlights the cell under the mouse:
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); }
参照