DataGridViewCellValidatingEventArgs.FormattedValue プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As DataGridViewCellValidatingEventArgs Dim value As Object value = instance.FormattedValue
書式指定済みの値への参照。

ユーザーがユーザー インターフェイス (UI) を通じて入力したテキストが、FormattedValue プロパティの値になります。この値が、セルの Value プロパティの値に解析する前に検証する対象となります。

CellValidating イベントを処理して、ユーザーが正の整数だけを入力するようにするコード例を次に示します。この例は VirtualMode のレファレンス トピックで取り上げている例の一部分です。
Private Sub dataGridView1_CellValidating(ByVal sender As Object, _ ByVal e _ As DataGridViewCellValidatingEventArgs) _ Handles dataGridView1.CellValidating Me.dataGridView1.Rows(e.RowIndex).ErrorText = "" Dim newInteger As Integer ' 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 Then Return If Not Integer.TryParse(e.FormattedValue.ToString(), newInteger) _ OrElse newInteger < 0 Then e.Cancel = True Me.dataGridView1.Rows(e.RowIndex).ErrorText = "the value must be a non-negative integer" End If End Sub
private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { dataGridView1.Rows[e.RowIndex].ErrorText = ""; 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 (!int.TryParse(e.FormattedValue.ToString() , out newInteger) || newInteger < 0) { e.Cancel = true; dataGridView1.Rows[e.RowIndex].ErrorText = "the value must be a non-negative integer"; } }
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; } }
private void dataGridView1_CellValidating(Object sender, DataGridViewCellValidatingEventArgs e) { int newInteger = 0; // Don't try to validate the 'new row' until finished // editing since there // is not any point in validating its initial value. if (dataGridView1.get_Rows().get_Item( e.get_RowIndex()).get_IsNewRow()) { return; } if (!(Int32.TryParse(e.get_FormattedValue().ToString(), newInteger)) || newInteger < 0) { e.set_Cancel(true); } } //dataGridView1_CellValidating

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDataGridViewCellValidatingEventArgs.FormattedValue プロパティを検索する場合は、下記のリンクをクリックしてください。

- DataGridViewCellValidatingEventArgs.FormattedValue プロパティのページへのリンク