Based on the project you sent me i think i know what you are doing.
Hopefully you have no problem interpreting this.
What you are trying to do is add controls to your form and handle the evnts without knowing what they are.
the fallowing shows by your code, how to identify the object and declare the correct addhandler for each new control.
You will need to make a sub routine for each type of event and assign handlers accordingly.
there are comments throughout the code attempting to explain whats happening.
Sub add_the_Controls(dtCtrlPlacement As DataTable)
Dim ctrl As Object
For I = 0 To dtCtrlPlacement.Rows.Count - 1
ctrl = objCtrls.cfgCtrls(dtCtrlPlacement.Rows(I), _
cnnAccessCtrlDB)
If ctrl.GetType() Is GetType(Windows.Forms.Button) Then
Dim x As Button = ctrl
AddHandler x.Click, AddressOf event_btnobject_Clicked
AddHandler x.MouseHover, AddressOf event_btnobject_hovered
Me.Controls.Add(x)
ElseIf ctrl.GetType() Is GetType(Windows.Forms.Label) Then
Dim x As Label = ctrl
AddHandler x.Click, AddressOf event_lblobject_Clicked
Me.Controls.Add(x)
End If
Next
End Sub
Sub event_btnobject_Clicked(sender As Button, e As EventArgs)
End Sub
Sub event_btnobject_hovered(sender As Button, e As EventArgs)
End Sub
Sub event_lblobject_Clicked(sender As Label, e As EventArgs)
End Sub