PDA

Click to See Complete Forum and Search --> : Sender Parameter - Name of Control


Bananafish
May 21st, 2002, 05:25 AM
When coding the equivelent of control arrays in vb.Net, I have been using event functions with multiple Handles parameters.

ie,

Private Sub mnuFileModify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileModify.Click, mnuFileInsert.Click, mnuFileDelete.Click


My question then is how to detect from the Sender parameter the name of the individual control.

I can use the following code to extract various properties - ie, the "Text" property - but I would prefer to actually refer to the Control Name (mnuFileInsert etc.)


Dim mnuX As MenuItem
mnuX = CType(sender, MenuItem)
if mnuX.Text.StartsWith("Insert" Then
...
End If


Can anyone help?

Cander
May 21st, 2002, 08:43 AM
sender.Name

Bananafish
May 21st, 2002, 09:18 AM
One of our standards here is to set "Option Strict On"
and Sender.Name doesn't work (it uses late binding).

I thought if I converted it to the menuitem class (or any other control class), there would be a Name property available - but there doesnt seem to be one.