473,396 Members | 1,779 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,396 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 1417
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.