DataGridViewCellEventArgs Class
Assembly: System.Windows.Forms (in system.windows.forms.dll)
The following code example demonstrates using CellMouseEnter and CellMouseLeave event handlers to determine whether a cell can be clicked. The example updates each ToolTipText property value to advertise the current image layout. This code is part of a larger example shown in How to: Work with Image Columns in the Windows Forms DataGridView Control.
Private Sub dataGridView1_CellMouseEnter(ByVal sender As Object, _ ByVal e As DataGridViewCellEventArgs) _ Handles dataGridView1.CellMouseEnter Dim markingUnderMouse As Bitmap = _ CType(dataGridView1.Rows(e.RowIndex). _ Cells(e.ColumnIndex).Value, Bitmap) If markingUnderMouse Is blank Then dataGridView1.Cursor = Cursors.Default ElseIf markingUnderMouse Is o OrElse markingUnderMouse Is x Then dataGridView1.Cursor = Cursors.No ToolTip(e) End If End Sub Private Sub ToolTip( _ ByVal e As DataGridViewCellEventArgs) Dim cell As DataGridViewImageCell = _ CType(dataGridView1.Rows(e.RowIndex). _ Cells(e.ColumnIndex), DataGridViewImageCell) Dim imageColumn As DataGridViewImageColumn = _ CType(dataGridView1.Columns(cell.ColumnIndex), _ DataGridViewImageColumn) cell.ToolTipText = imageColumn.Description End Sub Private Sub dataGridView1_CellMouseLeave(ByVal sender As Object, _ ByVal e As DataGridViewCellEventArgs) _ Handles dataGridView1.CellMouseLeave dataGridView1.Cursor = Cursors.Default End Sub
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.