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

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

DataGridViewCellCancelEventHandler デリゲート

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

DataGridView の CellBeginEdit イベントおよび RowValidating イベント処理するメソッド表します

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

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

パラメータ

sender

イベントソース

e

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

解説解説
使用例使用例

有効なトラックリリース日入力されたかどうかを DataGridViewCellCancelEventHandler デリゲート使用してチェックするコード例次に示します

Private Sub ValidateByRow(ByVal
 sender As Object, _
    ByVal data As DataGridViewCellCancelEventArgs)
 _
    Handles songsDataGridView.RowValidating

    Dim row As DataGridViewRow = _
        songsDataGridView.Rows(data.RowIndex)
    Dim trackCell As DataGridViewCell = _
        row.Cells(songsDataGridView.Columns("Track").Index)
    Dim dateCell As DataGridViewCell = _
        row.Cells(songsDataGridView.Columns("Release Date").Index)
    data.Cancel = Not (IsTrackGood(trackCell) _
        AndAlso IsDateGood(dateCell))
End Sub

Private Function IsTrackGood(ByRef
 cell As DataGridViewCell) As Boolean

    If cell.Value.ToString().Length = 0 Then
        cell.ErrorText = "Please enter a track"
        songsDataGridView.Rows(cell.RowIndex).ErrorText = _
            "Please enter a track"
        Return False
    ElseIf cell.Value.ToString().Equals("0")
 Then
        cell.ErrorText = "Zero is not a valid track"
        songsDataGridView.Rows(cell.RowIndex).ErrorText = _
            "Zero is not a valid track"
        Return False
    ElseIf Not Integer.TryParse(
 _
        cell.Value.ToString(), New Integer())
 Then
        cell.ErrorText = "A Track must be a number"
        songsDataGridView.Rows(cell.RowIndex).ErrorText = _
            "A Track must be a number"
        Return False
    End If
    Return True
End Function

Private Function IsDateGood(ByRef
 cell As DataGridViewCell) As Boolean

    If cell.Value Is Nothing
 Then
        cell.ErrorText = "Missing date"
        songsDataGridView.Rows(cell.RowIndex).ErrorText = _
            "Missing date"
        Return False
    Else
        Try
            DateTime.Parse(cell.Value.ToString())
        Catch ex As FormatException

            cell.ErrorText = "Invalid format"
            songsDataGridView.Rows(cell.RowIndex).ErrorText = _
                "Invalid format"

            Return False
        End Try
    End If
    Return True
End Function
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からDataGridViewCellCancelEventHandler デリゲートを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDataGridViewCellCancelEventHandler デリゲートを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDataGridViewCellCancelEventHandler デリゲート を検索

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2024 GRAS Group, Inc.RSS