前端之家收集整理的这篇文章主要介绍了
[VB.NET][问]如何让父窗体响应子窗体中的某一个自定义事件,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
[问]如何让父窗体响应子窗体中的某一个
自定义事件 各位,小弟有一问题请教: 如题: 1 在子窗体中定义一个事件 2 由父窗体来响应这个
自定义事件 __________________________________________________________________________ Public Class Form1 Private Sub aaa(ByVal str As String) Me.Text = str End Sub Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click Dim a As New Form2 AddHandler a.aaaaa,AddressOf Me.aaa a.ShowDialog() End Sub End Class Public Class Form2 Inherits Form Public Event aaaaa(ByVal str As String) Public Sub New() Dim b As New Button Me.Controls.Add(b) AddHandler b.Click,AddressOf Button1_Click End Sub Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) RaiseEvent aaaaa( dddddddddddddddddddddddddddddd ) End Sub End Class __________________________________________________________________________