473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Listen for form events......

Hi All,

I have a situation where I have two forms - FormA and FormB.

FormA has a list of Customers which when you double-click open the selected
customer.
FormB displays that Customer.
FormB has a public event called CustomerChanged(CustomerID as Int32) which
is raised with the current CustomerID when the form closes and the details
have changed.

What I want to do is have FormA know when the details in FormB have changed
so it can update the list details.
That is easy when you spawn one FormB and listen to it by declaring the
FormB as module level variable:

Public WithEvents frm as new FormB

and then Having a method PickupCustomerChanged which Handles
frm.CustomerChanged, pick up the CustomerID and updates the list entry:

Public Sub PickupCustomerChanged(CustomerID as Int32) Handles
frm.CustomerChanged

The question is how can I spawn more than one FormB??
The module level variable can only hold one form pointer/reference so the
PickupCustomerChanged method runs only when the last FormB that was opened
closes........

How can I monitor more than one form's events?

Thanks

Alex
Jul 21 '05 #1
1 1414
Hi,

After some rooting around and trying the AddHandler I seem to have something
working.

By using this to open FormB:

Dim frm as new FormB
FormB.GetCustomer(123)
FormB.Show
AddHandler FormB.CustomerChanged, AddressOf PickUpCustomerChanged

this seems to tap into the event for that SPECIFIC INSTANCE of FormB.

So you could spawn as many FormB's as you like, and the AddHandler would
point the delegate for the Raised event to the method on FormA

Great.

Alex
"Alex Stevens" <Al**********************@gcc.co.uk> wrote in message
news:OF**************@tk2msftngp13.phx.gbl...
Hi All,

I have a situation where I have two forms - FormA and FormB.

FormA has a list of Customers which when you double-click open the selected customer.
FormB displays that Customer.
FormB has a public event called CustomerChanged(CustomerID as Int32) which
is raised with the current CustomerID when the form closes and the details
have changed.

What I want to do is have FormA know when the details in FormB have changed so it can update the list details.
That is easy when you spawn one FormB and listen to it by declaring the
FormB as module level variable:

Public WithEvents frm as new FormB

and then Having a method PickupCustomerChanged which Handles
frm.CustomerChanged, pick up the CustomerID and updates the list entry:

Public Sub PickupCustomerChanged(CustomerID as Int32) Handles
frm.CustomerChanged

The question is how can I spawn more than one FormB??
The module level variable can only hold one form pointer/reference so the
PickupCustomerChanged method runs only when the last FormB that was opened
closes........

How can I monitor more than one form's events?

Thanks

Alex

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alex | last post by:
I am trying to determine if C# has the capabilities to listen for system events when the application does not have the window's focus. I am writing a windows application that I would like to run...
0
by: Eric | last post by:
Hi, I wonder if it is possible to listen to events from other applications that you have not written yourself and that you don't know anything about? Notepad or any other windows application for...
9
by: mBird | last post by:
I wrote a service that listens for broadcast messages from my firewall (UDP snmp trap messages) and parses and puts the data in an database. I'd also like to write an app that is a simple form...
4
by: Sean Connery | last post by:
I know I can merge a child forms menu into the MDI parent's mainmenu, but I would also like to listen for common events fired from the mainmenu that might be of interest to any child forms. Is...
6
by: Tom | last post by:
Rather than merge child menus, I would like for some common functionality between various MDI child forms to process an event fired from the main menu, depending on who is in focus. Is this...
3
by: Tulga Kalayci | last post by:
Hi All, I need advise on how to proceed in a area which I have no experience. The problem is related to a call center solution. When a call comes, call center software + server handles call and...
1
by: Alex Stevens | last post by:
Hi All, I have a situation where I have two forms - FormA and FormB. FormA has a list of Customers which when you double-click open the selected customer. FormB displays that Customer. FormB...
5
by: Ted Shab | last post by:
Hi, I'm trying to come up with a relatively simple multi-master replication solution. This is for multiple databases that need to be discreet, and change relatively infrequently (10-30 updates...
0
by: Magnus O. | last post by:
Hi! Is it possible to listen to volume changes in windows vista? My multimedia keys on my laptop controls the windows volume mixer but there is no OSD. Is it possible to listen to changed volume...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.