DataGridView.RowsRemoved イベントとは? わかりやすく解説

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

DataGridView.RowsRemoved イベント

メモ : このイベントは、.NET Framework version 2.0新しく追加されたものです。

行が DataGridView から削除されたときに発生します

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

Public Event RowsRemoved As
 DataGridViewRowsRemovedEventHandler
Dim instance As DataGridView
Dim handler As DataGridViewRowsRemovedEventHandler

AddHandler instance.RowsRemoved, handler
public event DataGridViewRowsRemovedEventHandler RowsRemoved
public:
event DataGridViewRowsRemovedEventHandler^ RowsRemoved {
    void add (DataGridViewRowsRemovedEventHandler^ value);
    void remove (DataGridViewRowsRemovedEventHandler^ value);
}
/** @event */
public void add_RowsRemoved (DataGridViewRowsRemovedEventHandler
 value)

/** @event */
public void remove_RowsRemoved (DataGridViewRowsRemovedEventHandler
 value)
JScript では、イベント使用できますが、新規に宣言することはできません。
解説解説
使用例使用例

このイベント使用してDataGridView残高列の値を更新するコード例次に示します

Private Sub CellValueChanged(ByVal
 sender As Object, _
    ByVal e As DataGridViewCellEventArgs) _
    Handles DataGridView1.CellValueChanged

    ' Update the balance column whenever the values of any cell changes.
    UpdateBalance()
End Sub

Private Sub RowsRemoved(ByVal
 sender As Object, _
    ByVal e As DataGridViewRowsRemovedEventArgs)
 _
    Handles DataGridView1.RowsRemoved

    ' Update the balance column whenever rows are deleted.
    UpdateBalance()
End Sub

Private Sub UpdateBalance()
    Dim counter As Integer
    Dim balance As Integer
    Dim deposit As Integer
    Dim withdrawal As Integer

    ' Iterate through the rows, skipping the Starting Balance Row.
    For counter = 1 To (DataGridView1.Rows.Count
 - 2)
        deposit = 0
        withdrawal = 0
        balance = Integer.Parse(DataGridView1.Rows(counter - 1)
 _
            .Cells("Balance").Value.ToString())

        If Not DataGridView1.Rows(counter)
 _
            .Cells("Deposits").Value Is
 Nothing Then

            ' Verify that the cell value is not an empty string.
            If Not DataGridView1.Rows(counter)
 _
                .Cells("Deposits").Value.ToString().Length
 = 0 Then
                deposit = Integer.Parse(DataGridView1.Rows(counter)
 _
                    .Cells("Deposits").Value.ToString())
            End If
        End If

        If Not DataGridView1.Rows(counter)
 _
            .Cells("Withdrawals").Value Is
 Nothing Then
            If Not DataGridView1.Rows(counter)
 _
                .Cells("Withdrawals").Value.ToString().Length
 = 0 Then
                withdrawal = Integer.Parse(DataGridView1.Rows(counter)
 _
                    .Cells("Withdrawals").Value.ToString())
            End If
        End If

        DataGridView1.Rows(counter).Cells("Balance").Value
 = _
            (balance + deposit + withdrawal).ToString()
    Next
End Sub
private void DataGridView1_CellValueChanged(
    object sender, DataGridViewCellEventArgs e)
{
    // Update the balance column whenever the value of any cell changes.
    UpdateBalance();
}

private void DataGridView1_RowsRemoved(
    object sender, DataGridViewRowsRemovedEventArgs e)
{
    // Update the balance column whenever rows are deleted.
    UpdateBalance();
}

private void UpdateBalance()
{
    int counter;
    int balance;
    int deposit;
    int withdrawal;

    // Iterate through the rows, skipping the Starting Balance row.
    for (counter = 1; counter < (DataGridView1.Rows.Count -
 1);
        counter++)
    {
        deposit = 0;
        withdrawal = 0;
        balance = int.Parse(DataGridView1.Rows[counter - 1]
            .Cells["Balance"].Value.ToString());

        if (DataGridView1.Rows[counter].Cells["Deposits"].Value
 != null)
        {
            // Verify that the cell value is not an empty string.
            if (DataGridView1.Rows[counter]
                .Cells["Deposits"].Value.ToString().Length != 0)
            {
                deposit = int.Parse(DataGridView1.Rows[counter]
                    .Cells["Deposits"].Value.ToString());
            }
        }

        if (DataGridView1.Rows[counter].Cells["Withdrawals"].Value
 != null)
        {
            if (DataGridView1.Rows[counter]
                .Cells["Withdrawals"].Value.ToString().Length != 0)
            {
                withdrawal = int.Parse(DataGridView1.Rows[counter]
                    .Cells["Withdrawals"].Value.ToString());
            }
        }
        DataGridView1.Rows[counter].Cells["Balance"].Value =
            (balance + deposit + withdrawal).ToString();
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridView クラス
DataGridView メンバ
System.Windows.Forms 名前空間
DataGridViewRowsRemovedEventHandler
DataGridViewRowsRemovedEventArgs
OnRowsRemoved
その他の技術情報
DataGridView コントロール (Windows フォーム)



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

辞書ショートカット

すべての辞書の索引

「DataGridView.RowsRemoved イベント」の関連用語

DataGridView.RowsRemoved イベントのお隣キーワード
検索ランキング

   

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



DataGridView.RowsRemoved イベントのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS