comcrack Posted July 1, 2003 Posted July 1, 2003 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 Quote [ () /\/\ [ |\ /\ [ |<
*Experts* Volte Posted July 1, 2003 *Experts* Posted July 1, 2003 .. what? What do you mean by a handle? Do you mean adding an item to a menu given its handle? Quote
comcrack Posted July 1, 2003 Author Posted July 1, 2003 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 Quote [ () /\/\ [ |\ /\ [ |<
*Experts* Volte Posted July 1, 2003 *Experts* Posted July 1, 2003 Do you mean a handler? You can do:AddHandler MyMenu.Click, AddressOf HandlerSubYou can assign as many events to the same sub as you want, as long as they are all the same kind of event. Quote
comcrack Posted July 1, 2003 Author Posted July 1, 2003 It say that HandlerSub is not declared. What I have to put there??? Quote [ () /\/\ [ |\ /\ [ |<
*Experts* mutant Posted July 1, 2003 *Experts* Posted July 1, 2003 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. Quote
comcrack Posted July 1, 2003 Author Posted July 1, 2003 ???? 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 Quote [ () /\/\ [ |\ /\ [ |<
*Experts* mutant Posted July 1, 2003 *Experts* Posted July 1, 2003 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. :) Quote
comcrack Posted July 1, 2003 Author Posted July 1, 2003 Dim MainframeTemp(1000000) As MainFrame It's the form MainFrame witch is called. Quote [ () /\/\ [ |\ /\ [ |<
comcrack Posted July 1, 2003 Author Posted July 1, 2003 There is MainFrame:mainframe.vb Quote [ () /\/\ [ |\ /\ [ |<
*Experts* mutant Posted July 1, 2003 *Experts* Posted July 1, 2003 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. Quote
comcrack Posted July 1, 2003 Author Posted July 1, 2003 How can I do the array list Quote [ () /\/\ [ |\ /\ [ |<
*Experts* mutant Posted July 1, 2003 *Experts* Posted July 1, 2003 Dim arrlist As New ArrayList() arrlist.Add(someobject) Quote
comcrack Posted July 1, 2003 Author Posted July 1, 2003 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? Quote [ () /\/\ [ |\ /\ [ |<
*Experts* mutant Posted July 1, 2003 *Experts* Posted July 1, 2003 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. Quote
comcrack Posted July 2, 2003 Author Posted July 2, 2003 It work. Thank you 100000 time. (or a list array) Quote [ () /\/\ [ |\ /\ [ |<
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.