K
Keith R
in my form load, I've added the following (along with the sub below)- but
when I run my test form and click on the buttons, I'm not getting the
msgbox. I added the tag on each button because I'll also have other buttons
on the form that I don't want to have use this event handler. I'm not sure
if my error is in the parameters being passed, or the way I'm referencing
the controls/buttons, or both. Any help would be greatly appreciated!
Keith
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'***********************
'Add FlagButtons common event handler
Dim FlagCtl As Control
Dim FlagBtn As Button
For Each FlagCtl In Me.Controls
If FlagCtl Is FlagBtn Then
If FlagCtl.Tag = "Filter" Then
AddHandler Control.MouseDown, AddressOf Me.mousendownhandler
End If
End If
Next
End Sub
Sub mousendownhandler(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
MsgBox(sender.text)
End Sub
when I run my test form and click on the buttons, I'm not getting the
msgbox. I added the tag on each button because I'll also have other buttons
on the form that I don't want to have use this event handler. I'm not sure
if my error is in the parameters being passed, or the way I'm referencing
the controls/buttons, or both. Any help would be greatly appreciated!
Keith
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'***********************
'Add FlagButtons common event handler
Dim FlagCtl As Control
Dim FlagBtn As Button
For Each FlagCtl In Me.Controls
If FlagCtl Is FlagBtn Then
If FlagCtl.Tag = "Filter" Then
AddHandler Control.MouseDown, AddressOf Me.mousendownhandler
End If
End If
Next
End Sub
Sub mousendownhandler(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
MsgBox(sender.text)
End Sub