Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hy,

 

 

Can anyone can tel me how to add a handle. I tryed the help of MSDN but I didn't understand.:confused:

 

 

And if you know how to put this handle there it will be real appreciated. --> Menu1.MenuItems.Add("hy",TheHandle)

 

 

Thank You

 

ComCrack

[ () /\/\ [ |\ /\ [ |<
Posted

I mean to add a handle to mybase like MyBase.Closing. to make a sub :

 

public sub MenuItem_click(byval Id as integer) handles mybase.menuclick

'...

end sub 

'...

private sub any_sub()
    Menu1.MenuItems.Add("hy", mybase.menuclick(id))
end sub

[ () /\/\ [ |\ /\ [ |<
  • *Experts*
Posted

Do you mean a handler?

 

You can do:

AddHandler MyMenu.Click, AddressOf HandlerSub

You can assign as many events to the same sub as you want, as long as they are all the same kind of event.

  • *Experts*
Posted
You have to put the name of your handling sub there, and make sure the arguments it accepts correspond to the ones that the event you are using passes in.
Posted

????

there is my two sub. the second is the sub witch I want to call when I click on the menu item declared in my first sub. I also need to send the id (NbMainFrame) when the menuitem is clicked.

 

Private Sub MenuItem66_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem66.Click
       Dim newmainframe As New MainFrame(NbMainFrame + 1, NbMainFrame + 1, Me)
       NbMainFrame += 1
       MainframeTemp(NbMainFrame) = newmainframe
       MainframeOpen(NbMainFrame) = True
       newmainframe.Show()
       Dim sendertemp As Object
       sendertemp = NbMainFrame
????? AddHandler MyMenu.Click, AddressOf HandlerSub ????
       Menu1.MenuItems.Add("Hy",???? What do I have to write Here???? (id))
       Menu1.MenuItems.Item(NbMainFrame + 3).Visible = True
   End Sub



   Private Sub MenuItem_Click(ByVal id As Integer) ??? What do I have to write Here????
       MainframeTemp(id).Activate()
   End Sub

[ () /\/\ [ |\ /\ [ |<
  • *Experts*
Posted

Private Sub MenuItem66_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem66.Click
       Dim newmainframe As New MainFrame(NbMainFrame + 1, NbMainFrame + 1, Me)
       NbMainFrame += 1
       MainframeTemp(NbMainFrame) = newmainframe
       MainframeOpen(NbMainFrame) = True
       newmainframe.Show()
       Dim sendertemp As Object
       sendertemp = NbMainFrame
       AddHandler MyMenu.Click, AddressOf MenuItem_Click
       Menu1.MenuItems.Add("Hy",MenuItem_Click)
       Menu1.MenuItems.Item(NbMainFrame + 3).Visible = True
   End Sub

   Private Sub MenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)         
         MainframeTemp(id).Activate()
   End Sub

You cant pick your own arguments for event handlers, but you can identify the menu that was clicked with the sender argument that is passed in.

Whats the MainframeTemp object, if I know that I can help you come up with the substitute for the id number.

:)

  • *Experts*
Posted

Maybe you could make your ID variable public to the whole class so you dont have to pass it between the sub.

Instead of declraing 1000000(!!) array members you could use an array list, where you can add objects to it without having to worry about the array capacity.

Posted

if do that :

Menu1.MenuItems.Add(NbMainFrame + 3, Menu1.MenuItems.Item(4))

When any of these menuitem is clicked, how can I know witch is clicked?

[ () /\/\ [ |\ /\ [ |<
  • *Experts*
Posted

You want to know what menu was clicked and raised the event in your MenuItem_Click handler? If yes, then:

(in your MenuItem_Click handler)

If sender Is somemenuitem Then
        MsgBox("some menu item was clicked")
End If

Substitute it with your object names and with what you want to do there.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...