473,387 Members | 1,569 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,387 software developers and data experts.

Problem Communicating Between Forms

I have a main form which has a list of items from a table on my
database. If I click one of these items it brings up a second form
which lets you edit the details for that item. If I change an item's
details and then close the edit form I want the main form to update its
datagrid by calling the sub I wrote which refreshes the dataset.

What is the best method of doing this; I know I can call commands after
a showdialog form but I really don't want to use showdialog instead of
show.

Any help would be greatly appreciated. Please try and be specific as
I'm still quite new to the Dot Net way of doing things.

Feb 5 '06 #1
2 1154
Jasper,

What is the best method of doing this; I know I can call commands after
a showdialog form but I really don't want to use showdialog instead of
show.

Why because if you use another from than you will have to do a lot with all
those extra forms that a user is opening meanwhile on the first form. You
have to prevent that your first form can be accessed. Showdialog does this
direct for you.

Cor
Feb 5 '06 #2
CMM
Simple Solution:

Have the first form subscribe to the second form's Closing event... like
this:

Dim frm as New Form2
AddHandler(frm.Closing, AddressOf MyForm2ClosingProc)
frm.Show

You can also create a new custom event in the second form that could
communicate additional info to the first form.

Better Solution
Create a global Notifier class that forms can subscribe to and "hear"
chatter from other forms. When the second form is closing it can do
something like: GlobalNotifier.SendNotification(Me,"Hey I'm Closing AND I
updated some data")

This is soooo simple to do.

'declare this in a global module
Public GlobalNotifier As New Notifier

'notifier class
Public Class Notifier

Public Event Notify(sender As Object, e As NotifyEventArgs)

Public Sub SendNotifications(sender As Object, message as String)
RaiseEvent Notify(sender, New NotifyEventArgs(message))
End Sub

End Class

'... I think you can figure out the rest.

"Jasper Jones" <ja*******@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I have a main form which has a list of items from a table on my
database. If I click one of these items it brings up a second form
which lets you edit the details for that item. If I change an item's
details and then close the edit form I want the main form to update its
datagrid by calling the sub I wrote which refreshes the dataset.

What is the best method of doing this; I know I can call commands after
a showdialog form but I really don't want to use showdialog instead of
show.

Any help would be greatly appreciated. Please try and be specific as
I'm still quite new to the Dot Net way of doing things.

Feb 5 '06 #3

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

Similar topics

1
by: Martin | last post by:
This is probably a very easy one but I just can't put my finger on the communicating events name:- I have a MDIform with a couple of child forms. The child forms scroll vertically at run time...
6
by: harry | last post by:
Hi, I have a program that runs on multiple client pc's. Occasionally one or more of those pc's use VPN to connect to another corporate network. When using VPN they need to set proxy server in...
3
by: Stan | last post by:
Hallo, I have developed an application in MS Access 2000 (Polish version) under MS Windows XP prof (also Polish). Now I would like to run this code on MS Windows XP EN and MS Access XP EN. I have...
0
by: Filips Benoit | last post by:
A particular form - always the same - sometimes becomes corrupt after saving. Error msg = The expression On Open you entered as the event property settings produced the following error: A...
1
by: Nothing | last post by:
I am trying to create an field on a form which is link to a table to store pictures. I have the field defined as follows: Name: Photofield1 Type: OLE Object I have created a form with this...
1
by: Serdar C. | last post by:
hello again, i have another question... i am writing a program with 2 windows forms... first form have a search button and several text buttons to list the data loaded from an sql database ...
6
by: AMeador | last post by:
I have a form where a user will check boxes next to items that have been completed. They will click a button on the form to mark the items as completed. When they do this, I will have the 'parent'...
1
by: Alan McIntosh | last post by:
i'm very new to VB.net (started today 13/4/2004) Simple question : how do I have a form open after pressing a button on me menu I can create menu, and a form where I want to gather some...
2
by: Tim | last post by:
I am trying to send a simple mail message using windows forms in VB.NET 2005. When executing the code, I get a general 'Configuration system failed to initialize' error message when the code...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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:
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.