2012年12月19日 星期三

dataGridView UserAddedRow event

參考來源
---
新增的事件順序:

1. Create a private module-level variable like this:

Public

Class frmMain

Private _UserAddedRowIndex As Integer = -1

...

2. Handle the UserAddedRow event like this:

Private

Sub dgvItems_UserAddedRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs) Handles dgvItems.UserAddedRow

_UserAddedRowIndex = Me.dgvItems.CurrentRow.Index

End Sub

3. Handle the RowValidating event like this:

Private

Sub dgvItems_RowValidating(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles dgvItems.RowValidating

If e.RowIndex = _UserAddedRowIndex Then MsgBox("User just finished entering a new row")

End Sub

4. Handle the RowValidated event like this:
4. Handle the RowValidated event like this:
4. Handle the RowValidated event like this:

Private Sub dgvItems_RowValidated(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvItems.RowValidated

_UserAddedRowIndex = -1
End Sub

沒有留言:

張貼留言