DataGridViewCellValueEventArgs::RowIndex Property
.NET Framework (current version)
Gets a value indicating the row index of the cell that the event occurs for.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Property Value
Type: System::Int32The index of the row containing the cell that the event occurs for.
The following code example handles the CellValuePushed event to store updates and new entries in a data store object. This example is part of a larger example available in the DataGridView::VirtualMode reference topic.
#pragma region Data store maintance
void VirtualConnector::dataGridView1_CellValueNeeded
(Object^ sender, DataGridViewCellValueEventArgs^ e)
{
if (store->ContainsKey(e->RowIndex))
{
// Use the store if the e value has been modified
// and stored.
e->Value = gcnew Int32(store->default[e->RowIndex]);
}
else if (newRowNeeded && e->RowIndex == numberOfRows)
{
if (dataGridView1->IsCurrentCellInEditMode)
{
e->Value = initialValue;
}
else
{
// Show a blank e if the cursor is just loitering
// over(the) last row.
e->Value = String::Empty;
}
}
else
{
e->Value = e->RowIndex;
}
}
void VirtualConnector::dataGridView1_CellValuePushed
(Object^ sender, DataGridViewCellValueEventArgs^ e)
{
String^ value = e->Value->ToString();
store[e->RowIndex] = Int32::Parse(value,
CultureInfo::CurrentCulture);
}
#pragma endregion
.NET Framework
Available since 2.0
Available since 2.0
Show: