Unanswered: Button Handler Being called multiple times??
Hello folks - I have a question for you:
I have a Class (class1), that inherits a Windows.Form. On a button click, it passes a reference of itself to another class (class2). The aim is to handle all of the form control events in class2, thus freeing up coding space in class1.
Class 2 looks like this:
Public Class Class2
Dim cl1 As Class1
Dim iCode As Integer
Public SetData(ByVal iCode As Integer, ByRef cl1 As Class1)
Private Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Private Sub btn2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Private Sub btn3_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Private Sub btn4_Click(ByVal sender As Object, ByVal e As System.EventArgs)
There are 3 buttons in Class1 that create a new instance of Class2 and call the SetData passing a different value for iCode but the same created instance of Class1. The problem I have is if you click btn3 for example, after the message box is displayed, it's handler is automatically called again, sometimes up to 4 times without me doing anything! I've experimented pressing the 4 buttons in Class1 and pressing any of the buttons handled in Class2 and sometimes the associated message box is displayed just the once (which is what should be happening), and on other occassions it can be displayed multiple times.
Can someone elighten me as to what's wrong with my code?