DataGridViewCellParsingEventArgs.ParsingApplied 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定值,指出儲存格的值是否已經剖析成功。
public:
property bool ParsingApplied { bool get(); void set(bool value); };
public bool ParsingApplied { get; set; }
member this.ParsingApplied : bool with get, set
Public Property ParsingApplied As Boolean
屬性值
如果儲存格的值已經剖析成功,則為 true
,否則為 false
。 預設為 false
。
範例
下列程式碼範例會在成功剖析儲存格的值時設定 ParsingApplied 為 true
。
// Handling CellParsing allows one to accept user input, then map it to a different
// internal representation.
void dataGridView1_CellParsing( Object^ /*sender*/, DataGridViewCellParsingEventArgs^ e )
{
if ( this->dataGridView1->Columns[ e->ColumnIndex ]->Name->Equals( "Release Date" ) )
{
if ( e != nullptr )
{
if ( e->Value != nullptr )
{
try
{
// Map what the user typed into UTC.
e->Value = DateTime::Parse( e->Value->ToString() ).ToUniversalTime();
// Set the ParsingApplied property to
// Show the event is handled.
e->ParsingApplied = true;
}
catch ( FormatException^ /*ex*/ )
{
// Set to false in case another CellParsing handler
// wants to try to parse this DataGridViewCellParsingEventArgs instance.
e->ParsingApplied = false;
}
}
}
}
}
// Handling CellParsing allows one to accept user input, then map it to a different
// internal representation.
private void dataGridView1_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
{
if (this.dataGridView1.Columns[e.ColumnIndex].Name == "Release Date")
{
if (e != null)
{
if (e.Value != null)
{
try
{
// Map what the user typed into UTC.
e.Value = DateTime.Parse(e.Value.ToString()).ToUniversalTime();
// Set the ParsingApplied property to
// Show the event is handled.
e.ParsingApplied = true;
}
catch (FormatException)
{
// Set to false in case another CellParsing handler
// wants to try to parse this DataGridViewCellParsingEventArgs instance.
e.ParsingApplied = false;
}
}
}
}
}
' Handling CellParsing allows one to accept user input, then map it to a different
' internal representation.
Private Sub dataGridView1_CellParsing(ByVal sender As Object, _
ByVal e As DataGridViewCellParsingEventArgs) _
Handles dataGridView1.CellParsing
If Me.dataGridView1.Columns(e.ColumnIndex).Name = _
"Release Date" Then
If e IsNot Nothing Then
If e.Value IsNot Nothing Then
Try
' Map what the user typed into UTC.
e.Value = _
DateTime.Parse(e.Value.ToString()).ToUniversalTime()
' Set the ParsingApplied property to
' Show the event is handled.
e.ParsingApplied = True
Catch ex As FormatException
' Set to false in case another CellParsing handler
' wants to try to parse this DataGridViewCellParsingEventArgs instance.
e.ParsingApplied = False
End Try
End If
End If
End If
End Sub
備註
會 DataGridViewCellParsingEventHandler 設定 ParsingApplied 屬性,指出新儲存格值是否成功剖析,而且不需要進一步轉換。