473,386 Members | 1,819 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,386 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 2562
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.