Visual Basic Development Bookmark and Share   
 Home > Visual Basic Language > Manage Events
 

Manage Events

Hito All,
i'vedeclared a varible withevents in aMDIFormwhere i manage event of a class.


I whould like to manage those events in the forms who i shown on the container whitoud declare any others varibles.
Does it is possibile in vb2005?

E.x.:

public class MyMDIForm
private withevents cMyClass as MyClassName

private subManagedFunction(...) Handle cMyClass.Event

end sub

end class


'this is the class shown on MyMDIForm (MDIChild)

public class MyMDIChild

private sub ManagedFunction(...) Handle cMyClass.Event<------- Does it is possible whit any statment?

end sub

end class

THANKS,
Domenico.
Mengo-Solutions  Friday, September 26, 2008 7:08 AM
Hey Domenico,

Can u be a bit precise as to what u really want to do ?

If u want to handle events of the MDI child, in the MDI parent, you can easily accomplish the same by using
the 'Raise Event' method.

To be bit precise,
you can create a Event in the child class and then when required raise a event in the child and write the handler of the same in the parent form. So whenever the event is raised it is handled in the main form (MDI parent) insted of the child form.
Rohan W  Sunday, September 28, 2008 4:41 PM

Hi,

I don't know if this is what you are after fully but here goes.

Here MdiParent and MdiChild1 are both FORMs.

Please note the application namespace here is the default of WindowsApplication1

change it to suit your application ( progam ) name in the code below.

Add one button to the MdiParent form to try this code please.




Public Class MdiParent

Private Sub MdiParent_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me.Text = "MdiParent"

AddHandler Button1.Click, AddressOf WindowsApplication1.MdiChild1.ChildSub1

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'First this message is shown.>>

MessageBox.Show("Hi from the MdiParent FORM!!")

'But this Button.Click SUB also has a HANDLE to the SUB
'WindowsApplication1.MdiChild1.ChildSub1
'hence why you see the second message.

'Then I show the CHILD FORM MdiChild1.>>

MdiChild1.Show()

End Sub

End Class




Public Class MdiChild1
Public Sub ChildSub1() '<------- Does it is possible with any statement?
MessageBox.Show("Hi there from FORM MdiChild1!!")
End Sub
End
Class




Regards,

John


For links to VB.Net tutorials see here.>> http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/29f2179b-997b-4115-a96d-a0834853b835
John Anthony Oliver  Friday, September 26, 2008 10:50 PM
Hey Domenico,

Can u be a bit precise as to what u really want to do ?

If u want to handle events of the MDI child, in the MDI parent, you can easily accomplish the same by using
the 'Raise Event' method.

To be bit precise,
you can create a Event in the child class and then when required raise a event in the child and write the handler of the same in the parent form. So whenever the event is raised it is handled in the main form (MDI parent) insted of the child form.
Rohan W  Sunday, September 28, 2008 4:41 PM

You can use google to search for other answers

Custom Search

More Threads

• Save/Delete does not work
• Stopping Windows from loading...
• Vbscript - delete locked files
• read exif from file
• ms access db how do i run an sql query and load result in textbox
• How do you add values that are in a listbox/
• Question about PrintDialog.AllowSelection
• some pointers please - what areas to look in?
• Restrict user to switch btw child forms in Mdi parent form.
• Question regarding the DESIGN of VB.Net language syntax, particularly the event SUB headers.