Problem in Me.ActiveControls

Hi,
I have a toolstripcontainer defined and i have 2 buttons inside the toolstrip. I want to use the Me.Activecontrols.Name to check the button that was clicked, but it always returns the toolstrip control name. Let me know how to get the button that was clicked with Me.ActiveControls.Name

Private

Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn.Click

MsgBox(

Me.ActiveControl.Name)

End Sub

Thanks,
Kris



Answer this question

Problem in Me.ActiveControls

  • BobLusk

    If all you want to get is the button that was clicked then use the sender parameter. It should be the object that raised the event (in this case, the button).

    The only problem is that sender is an object rather than a button. You'll need to cast it to a button in order to use it. Sorry, I can't remember how to cast in VB.

    To check if I'm right, just do

    MsgBox(sender.GetType().Name)

    which should print out what type sender really is.



  • Luis Ayala

    hi,
    Is your problem solved 
    Thank you,
    Bhanu.


  • mak101

    Are you adding Toolstripbutton or regular Windows Forms buttons to the ToolStripContentPanel

    -Mamta


  • Problem in Me.ActiveControls