DataGridViewCellValueEventArgs::Value Property
.NET Framework (current version)
Gets or sets the value of the cell that the event occurs for.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Use this property to inspect the cell's value when handling an event, or to communicate the cell's current value if creating an event.
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: