473,325 Members | 2,774 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,325 software developers and data experts.

Communication between forms

I have multiple Mdi Child forms.

Form1 is displaying all the orders list,
Form2 is displaying all the product list.

When I rename a Product name on Form3, I wanted to update contents in Form1
and 2.

Right now the Function renaming the Product is calling
reload functions in Form1 and 2, but its not refreshed.

Thanks In advance for your help.

Apr 20 '06 #1
8 2557
VJ
You may want to look into the concepts of delegates and events... Its more
like when you click a button, you write code in response to the click, in
the click event. So you will write a delegate/event in Form3 and subscribe
that in Form1 and Form 2, to perform the update in the notification event.
you have to implement this event for your product object... and since
product object is sued in Form 1 and Form 2, you can subscribe to it in the
Form and perform the action on the update event... Codeproject.com or any
vbproject samples websites have simple samples that explain the concept....,
if you google you will get them

VJ

"Selva Chinnasamy" <se*****************@online.nospam> wrote in message
news:OP**************@TK2MSFTNGP05.phx.gbl...
I have multiple Mdi Child forms.

Form1 is displaying all the orders list,
Form2 is displaying all the product list.

When I rename a Product name on Form3, I wanted to update contents in
Form1
and 2.

Right now the Function renaming the Product is calling
reload functions in Form1 and 2, but its not refreshed.

Thanks In advance for your help.


Apr 20 '06 #2
Hi Selva,
Thank you for posting. From your post, my understanding on this issue is:
how to update contents in Form1 and Form2 when the Product name in Form3
changed. If I'm off base, please feel free to let me know.

You can define an event for the change of the product name and write a
method to trigger the event when the product name changes in Form3. Then
subscribe the event and define corresponding event handling methods in
Form1 and Form2. Thus when the product name in Form3 changes, the event
will be raised and the corresponding event handling methods in Form1 and
Form2 will be called.
The following is a sample.

// event defined in Form3
public delegate void ProductNameChangedEventHandler(int productID);
public event ProductNameChangedEventHandler EvtProductNameChanged;
private void OnProductNameChanged(int id)
{
if (EvtProductNameChanged != null)
{
EvtProductNameChanged(id);
}
}

// add reference variable of a instance of Form3 ,subscribe the event and
define the handling method
public Form3 frm3 = null;
public Form1()
{
InitializeComponent();
frm3.EvtProductNameChanged += new
Form3.ProductNameChangedEventHandler(frm3_EvtProdu ctNameChanged);
}
void frm3_EvtProductNameChanged(int productID)
{
// add your update process here
}

You should assign the instance of Form3 to the reference variable "frm3"
of Form1 in the MDI Parent.

Hope this is helpful to you.
Please don't hesitate to tell me if you have any other concerns, or need
anything else.
Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Apr 21 '06 #3
Hi Linda,

Thanks for your post. It is helpful to me as well. I'm not that strong
on delegates.

But since this is a VB newsgroup, could you explain how the same thing
would be done in VB.NET ? Would it be as simple as converting the code
to VB.NET ?

Thanks in advance,

Regards,

Cerebrus.

Apr 21 '06 #4
Hi Cerebrus,

The following is a sample written in VB.NET.
// event defined in Form3
Public Event EvtProductNameChanged(ByVal productID As Integer)
Private Sub OnProductNameChanged(ByVal id As Integer)
RaiseEvent EvtProductNameChanged(id)
End Sub

// add reference variable of a instance of Form3 , define the event
handling method
Public WithEvents frm3 As Form3
Private Sub frm3_EvtProductNameChanged(ByVal productID As Integer)
Handles frm3.EvtProductNameChanged
' add your update process here
End Sub

You should assign the instance of Form3 to the reference variable "frm3"
of Form1 in the MDI Parent.
Hope this is helpful to you.

Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Apr 21 '06 #5
Thank you Linda, much appreciated.

Regards,

Cerebrus.

Apr 21 '06 #6
Hi Cerebrus, you're welcome!
Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Apr 24 '06 #7
Thanks A Bunch Linda.

Selva

"Linda Liu [MSFT]" wrote:
Hi Cerebrus,

The following is a sample written in VB.NET.
// event defined in Form3
Public Event EvtProductNameChanged(ByVal productID As Integer)
Private Sub OnProductNameChanged(ByVal id As Integer)
RaiseEvent EvtProductNameChanged(id)
End Sub

// add reference variable of a instance of Form3 , define the event
handling method
Public WithEvents frm3 As Form3
Private Sub frm3_EvtProductNameChanged(ByVal productID As Integer)
Handles frm3.EvtProductNameChanged
' add your update process here
End Sub

You should assign the instance of Form3 to the reference variable "frm3"
of Form1 in the MDI Parent.
Hope this is helpful to you.

Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Apr 24 '06 #8
Hi Selva,

You are welcome!
If you have any other questions or concerns, please don't hesitate to
contact us. It is always our pleasure to be of assistant.

Have a nice day!
Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Apr 25 '06 #9

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

Similar topics

4
by: Dean L. Howen | last post by:
Please show me advise. My problem is: how to communication between forms? I have 3 forms: The 1st: parent form: is MDI --> I call parentForm The 2nd: child form is called by parentForm...
2
by: aaa | last post by:
Hi I need to perform simple comunication towards my Windows.Forms clients. Service running on server needs to contact/notify client apps running in the network if certain event accurs. Upon this...
3
by: Maheshkumar.R | last post by:
Hi groups, How i can command over the MDI CHIlD forms created dynamically at runtime from PARENT. Let say, i have generated 5 mdichild forms, but i want to work with child form1 from MDI...
7
by: Dan Walls | last post by:
Hi, I just had a question regarding forms authentication using a SQL database backend. If my (planned)architecture is: Internet -> firewall -> DMZ (IIS - access to User Interface) -> Firewall...
2
by: Jim Shank | last post by:
I am really trying to find the best OOP way of doing this. I have a parent MDI form with multiple children and I am trying to communicate variables between them. I have been able to successfully...
21
by: dast | last post by:
Hi, I'm having trouble letting my background thread tell my main thread what to do. I'm trying to tell my main thread to open a form, but when my background thread ends, the form that I...
5
by: Mo | last post by:
Hi, I have an application where I read a serial port data from a barcode and set the labels on a form. I also have a textbox and button where you can enter the data and here is the problem. if I...
0
by: bacjoe | last post by:
I am new to writing multi-threaded code and am working on a Windows forms MDI application. There is an MDI Form that can have 0 to many MDI Children. The MDI form starts a thread that is used to...
6
by: ecir.hana | last post by:
Hi, let's say I have two scripts: one does some computations and the other one is a graphical front end for launching the first one. And both run in separate processes (front end runs and that it...
2
by: klimmer | last post by:
Hello, I'am used to work with PHP and MySQL on webbased application. I have to make for my colleagues a program that have to follow a few dessistions (path) like a flowchart. The result shood...
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
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.