'代码中Button控件自行在窗体中添加并改名
***********************************父窗体代旦吵码:
Public Class Form1
Public Sub From1_保存Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles From1_保存Button.Click
Select Case sender.name
Case "From1_保存Button"
MsgBox("提交的窗体是From1")
Case "Form2_提交Button"笑迟誉碰段
MsgBox("提交的窗体是From2")
End Select
Form2.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_显示子窗体.Click
Form2.ShowDialog()
End Sub
End Class
***********************************子窗体代码:
Public Class Form2
Private Sub Form2_提交Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Form2_提交Button.Click
Form1.From1_保存Button_Click(Form2_提交Button, New System.EventArgs)
End Sub
End Class
***********************************
方法满多的,起码三四种,比如用一个全局变量保存当前提交窗体名,执行操作的代码读取这个全局变量就行。最方便的应该是做过程
Public Sub DateBaseAdd(ByVal From As Form)
,然后父窗体跟子窗体都能调用这个全局过程,同时传入窗体名称