DataGridView::CellMouseLeave Event
.NET Framework (current version)
Occurs when the mouse pointer leaves a cell.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
For more information about handling events, see NIB: Consuming Events.
The following code example shows a CellMouseLeave event handler in a Tic-Tac-Toe game implementation that uses image columns in a DataGridView control. The event handler resets the cursor and ToolTip, which are set in a CellMouseEnter event handler.
This code is part of a larger example shown in How to: Work with Image Columns in the Windows Forms DataGridView Control.
void dataGridView1_CellMouseEnter( Object^ sender, DataGridViewCellEventArgs^ e ) { Bitmap^ markingUnderMouse = dynamic_cast<Bitmap^>(dataGridView1->Rows[ e->RowIndex ]->Cells[ e->ColumnIndex ]->Value); if ( markingUnderMouse == blank ) { dataGridView1->Cursor = Cursors::Default; } else if ( markingUnderMouse == o || markingUnderMouse == x ) { dataGridView1->Cursor = Cursors::No; ToolTip(e,true); } } void ToolTip( DataGridViewCellEventArgs^ e, bool showTip ) { DataGridViewImageCell^ cell = dynamic_cast<DataGridViewImageCell^>(dataGridView1->Rows[ e->RowIndex ]->Cells[ e->ColumnIndex ]); DataGridViewImageColumn^ imageColumn = dynamic_cast<DataGridViewImageColumn^>(dataGridView1->Columns[ cell->ColumnIndex ]); if ( showTip ) cell->ToolTipText = imageColumn->Description; else { cell->ToolTipText = String::Empty; } } void dataGridView1_CellMouseLeave( Object^ sender, DataGridViewCellEventArgs^ e ) { ToolTip( e, false ); dataGridView1->Cursor = Cursors::Default; }
.NET Framework
Available since 2.0
Available since 2.0
Show: