DataGridViewCellEventArgs Class
Provides data for DataGridView events related to cell and row operations.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The DataGridViewCellEventArgs type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | DataGridViewCellEventArgs | Initializes a new instance of the DataGridViewCellEventArgs class. |
| Name | Description | |
|---|---|---|
![]() | ColumnIndex | Gets a value indicating the column index of the cell that the event occurs for. |
![]() | RowIndex | Gets a value indicating the row index of the cell that the event occurs for. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
The DataGridViewCellEventArgs class provides data for the following DataGridView events:
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 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
