DataGridViewCellEventArgs Class
.NET Framework 2.0
Note: This class is new in the .NET Framework version 2.0.
Provides data for DataGridView events related to cell and row operations.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
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 void dataGridView1_CellMouseEnter(object sender, DataGridViewCellEventArgs e) { Bitmap markingUnderMouse = (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); } } private void ToolTip(DataGridViewCellEventArgs e, bool showTip) { DataGridViewImageCell cell = (DataGridViewImageCell) dataGridView1 .Rows[e.RowIndex].Cells[e.ColumnIndex]; DataGridViewImageColumn imageColumn = (DataGridViewImageColumn) dataGridView1.Columns[cell.ColumnIndex]; if (showTip) cell.ToolTipText = imageColumn.Description; else { cell.ToolTipText = String.Empty; } } private void dataGridView1_CellMouseLeave(object sender, DataGridViewCellEventArgs e) { ToolTip(e, false); dataGridView1.Cursor = Cursors.Default; }
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.