-1
我想根据从DataGridView中选择的行打开同一表单的多个实例。 我目前的代码有效,但在进入下一个之前等待每个表单关闭。 我需要同时打开表格,但仍然要通过事件向主窗体回报。VB .Net与事件相同的多个实例
Public Class frmARLog
Private WithEvents edit As frmEditARLog
'WithEvents: indicate that we want to receive events raised by this object
Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
fill()
End Sub
Sub fill()
Dim AR As AltARLog = New AltARLog
dgvARLog.DataSource = AR.getTable
End Sub
Private Sub btnEdit_Click(sender As Object, e As EventArgs) Handles btnEdit.Click
Dim iRowIndex As Integer
For i As Integer = 0 To dgvARLog.SelectedCells.Count - 1
iRowIndex = dgvARLog.SelectedCells.Item(i).RowIndex
openEditForm(dgvARLog.Rows(iRowIndex).Cells(0).Value.ToString, iRowIndex)
Next
End Sub
Sub openEditForm(arid As Integer, row As Integer)
edit = New frmEditARLog(arid)
AddHandler edit.FormClosing, AddressOf ItIsClosing
AddHandler edit.FormClosed, AddressOf ItIsClosed
edit.ShowDialog(Me)
End Sub
Private Sub ItIsClosing(sender As Object, e As FormClosingEventArgs)
If edit.Successful Then
fill()
End If
RemoveHandler edit.FormClosing, AddressOf ItIsClosing
End Sub
Private Sub ItIsClosed(sender As Object, e As FormClosedEventArgs)
RemoveHandler edit.FormClosed, AddressOf ItIsClosed
edit = Nothing
End Sub
End Class
关于注册事件的资源的任何建议。 – Talon06
您可以像现在一样注册事件。 –