'//////////////////////////////Form1.vb////////////////////// Public Class Form1 Private m_TextCtrls As New TextControls Private Sub Form1_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed m_TextCtrls = Nothing End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.Button1.Text = "閉じる" Me.Button2.Text = "全てのTextBoxをクリアする" Me.Button3.Text = "TextBox2のデータを取得してみる" Me.Label1.Text = "適当にTextBoxのTextを変更してみて下さい。" m_TextCtrls.AddItem(Me.TextBox1) m_TextCtrls.AddItem(Me.TextBox2) m_TextCtrls.AddItem(Me.TextBox3) AddHandler m_TextCtrls.TextControls_UpDated, AddressOf TextControls_UpDated_Handler End Sub Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Close() End Sub Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click m_TextCtrls.ClearAllText() End Sub Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click MessageBox.Show(m_TextCtrls.Items(1).Text) End Sub Private Sub TextControls_UpDated_Handler(ByVal pText As TextBox) Me.Label2.Text = pText.Name & " のデータが変更されました。" End Sub End Class