DataGridViewCellValidatingEventHandler デリゲートとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGridViewCellValidatingEventHandler デリゲートの意味・解説 

DataGridViewCellValidatingEventHandler デリゲート

メモ : このデリゲートは、.NET Framework version 2.0新しく追加されたものです。

DataGridView コントロールの CellValidating イベント処理するメソッド表します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Delegate Sub DataGridViewCellValidatingEventHandler
 ( _
    sender As Object, _
    e As DataGridViewCellValidatingEventArgs _
)
Dim instance As New DataGridViewCellValidatingEventHandler(AddressOf
 HandlerMethod)
public delegate void DataGridViewCellValidatingEventHandler
 (
    Object sender,
    DataGridViewCellValidatingEventArgs e
)
public delegate void DataGridViewCellValidatingEventHandler
 (
    Object^ sender, 
    DataGridViewCellValidatingEventArgs^ e
)
/** @delegate */
public delegate void DataGridViewCellValidatingEventHandler
 (
    Object sender, 
    DataGridViewCellValidatingEventArgs e
)
JScript では、デリゲート使用できますが、新規に宣言することはできません。

パラメータ

sender

イベント送信元へ参照

e

イベント データ格納している DataGridViewCellValidatingEventArgs。

解説解説
使用例使用例

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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellValidating イベント
DataGridView.CellValidated イベント
DataGridView.CellValuePushed イベント
DataGridViewCellValidatingEventArgs クラス
DataGridViewCell クラス



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

DataGridViewCellValidatingEventHandler デリゲートのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataGridViewCellValidatingEventHandler デリゲートのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS