DataGridViewCellValidatingEventArgs::FormattedValue Property
.NET Framework (current version)
Gets the formatted contents of the cell that needs to be validated.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The text entered by the user through the user interface (UI) becomes the FormattedValue property value. This is the value that you can validate before it is parsed into the cell Value property value.
The following code example handles the CellValidating event to ensure that only positive integers are entered by the user. This example is part of a larger example available in the VirtualMode reference topic.
void VirtualConnector::dataGridView1_CellValidating (Object^ sender, DataGridViewCellValidatingEventArgs^ e) { int newInteger; // Don't try to validate the 'new row' until finished // editing since there // is not any point in validating its initial value. if (dataGridView1->Rows[e->RowIndex]->IsNewRow) { return; } if (!Int32::TryParse(e->FormattedValue->ToString(), newInteger) || (newInteger < 0)) { e->Cancel = true; } }
.NET Framework
Available since 2.0
Available since 2.0
Show: