DataGridViewCellEventArgs Class
Provides data for DataGridView events related to cell and row operations.
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.
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; }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
