DataGridViewCellEventArgs Class
.NET Framework 3.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 Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: