我在panel p1中动态添加了一组按钮 并在窗口click事件中加入下面代码
但是 只要单击panel就会触发按钮事件 怎么回事
For Each c As WinForm.Control In e.Form.Controls("p1").children
If Typeof c Is WinForm.button AndAlso c.name.StartsWith("btn") Then
Dim b As WinForm.button = c
''MessageBox.show(c.name)
Dim fl As String = ProjectPath & "bin\temp\" & b.text
'' MessageBox.show(fl)
If FileSys.FileExists(fl) Then '如果本地存在同名文件且CRC校验值相同
'则直接使用本地文件
Else '否则从数据库提取文件
Dim tj As String
tj=c.name.Replace("btn-","")
Dim dr As DataRow=DataTables("附件").sqlfind("uid='" & tj.Split("-")(0) & "' and 文件名='" & tj.Split("-")(1) & "'")
If dr IsNot Nothing Then
If dr.SQLLoadFile("附件",fl) = True Then '如果提取文件失败
''Messagebox.Show("附件提取失败,可能并不存在附件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
End If
End If
End If
Dim Proc As New Process '打开文件
Proc.File = fl
Proc.Start()
End If
Next