473,387 Members | 1,650 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.

Communicating between forms...

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' form
instantiate another form where the details of this completed event will
be entered. Once the data is entered on this 'child' form, the data
entered should be updated/added to the database. The 'child' form also
has 'Cancel' and 'Cancel All' buttons. When the user hits 'Cancel',
the 'child' child form will not update/add the data and it will close.
If multiple items have been marked as complete in the 'parent' form,
the parent form will then open a new 'child' form for the details of
the next completed item, and so on, and so on. However, if the 'Cancel
All' button is hit, I want the process to stop. What is the best way to
make this work? How will the data from clicking 'Cancel All' get back
to the 'parent' form? I'm referring to the forms as 'Parent' and
'Child' as they are NOT MDI forms. I am a relative newbie to this stuff
so please be gentle in your answer ;) Thanks!

Nov 17 '05 #1
6 1439
I think the simplest is to have a variable with the form that processed the
data update, something like:

bool bCommitData = false;

Initially false until the entire process goes through all child forms and
the last form processes the OK button, in which case bCommitData = true. If
it is true then update database.

However this will only work if the parent of all forms has the database
update code in it. You will just want to update the entire database if the
process of going through all forms is completed. Then at the very end, send
all updates to the database.

"AMeador" <am******@tampabay.rr.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
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' form
instantiate another form where the details of this completed event will
be entered. Once the data is entered on this 'child' form, the data
entered should be updated/added to the database. The 'child' form also
has 'Cancel' and 'Cancel All' buttons. When the user hits 'Cancel',
the 'child' child form will not update/add the data and it will close.
If multiple items have been marked as complete in the 'parent' form,
the parent form will then open a new 'child' form for the details of
the next completed item, and so on, and so on. However, if the 'Cancel
All' button is hit, I want the process to stop. What is the best way to
make this work? How will the data from clicking 'Cancel All' get back
to the 'parent' form? I'm referring to the forms as 'Parent' and
'Child' as they are NOT MDI forms. I am a relative newbie to this stuff
so please be gentle in your answer ;) Thanks!

Nov 17 '05 #2
I was planning to put the data update code in the 'child' form.
These items are not dependant on each other, so if the process is
stopped in the middle, that would be fine. But even in your example
above, I still don't know the best way to go about letting the 'parent'
form know that a child has recived a 'Cancel All' or, if doing it as
you suggested, how to return the data collected in the child to the
parent. Would this be done by the use of some global array of objects?
Or, should I have the 'child' form fire some kind of an event at the
'parent' level before it closes down? If something like this was done,
how would you do that? Or, is there a better way that I'm not thinking
of? My code background is not very large at this point in relation to
object oriented and event driven approaches.

Nov 17 '05 #3
http://spaces.msn.com/members/staceyw/Blog/cns!1pnsZpX0fPvDxLKC6rAAhLsQ!351.entry

--
William Stacey, MVP
http://mvp.support.microsoft.com

"AMeador" <am******@tampabay.rr.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
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' form
instantiate another form where the details of this completed event will
be entered. Once the data is entered on this 'child' form, the data
entered should be updated/added to the database. The 'child' form also
has 'Cancel' and 'Cancel All' buttons. When the user hits 'Cancel',
the 'child' child form will not update/add the data and it will close.
If multiple items have been marked as complete in the 'parent' form,
the parent form will then open a new 'child' form for the details of
the next completed item, and so on, and so on. However, if the 'Cancel
All' button is hit, I want the process to stop. What is the best way to
make this work? How will the data from clicking 'Cancel All' get back
to the 'parent' form? I'm referring to the forms as 'Parent' and
'Child' as they are NOT MDI forms. I am a relative newbie to this stuff
so please be gentle in your answer ;) Thanks!


Nov 17 '05 #4
You can implement an attribute on your child form called bCancelAll for
example, initially set to false. Then using the C# attribute featue you can
write something like this in your child forms:

public bool IsCancelAll {
get
{
return bCancelAll;
}
}

also assign mrCancel value to both Cancel and Cancel All buttons.

in your main (parent) form something like this:

ChildForm1 form1 = new ChildForm1(this);
bool x = false, y = false, z = false;

DialogResult formResult = form1.ShowModal();
if (formResult == DialogResult.Cancel) {
if (form1.IsCancelAll) {
// do something because Cancel All was pressed
}
} else {
// OK button pressed
x = form1.CKBox1.Checked;
y = form1.CKBox2.Checked;
z = form1.CKBox3.Checked;
}

This is just a generic example so you can see the structure.
Does that give you any ideas?

"AMeador" <am******@tampabay.rr.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I was planning to put the data update code in the 'child' form.
These items are not dependant on each other, so if the process is
stopped in the middle, that would be fine. But even in your example
above, I still don't know the best way to go about letting the 'parent'
form know that a child has recived a 'Cancel All' or, if doing it as
you suggested, how to return the data collected in the child to tre he
parent. Would this be done by the use of some global array of objects?
Or, should I have the 'child' form fire some kind of an event at the
'parent' level before it closes down? If something like this was done,
how would you do that? Or, is there a better way that I'm not thinking
of? My code background is not very large at this point in relation to
object oriented and event driven approaches.

Nov 17 '05 #5
I think this may be what I'm looking for. Using the exampe you gave, I
will have form1 close if its cancel button is clicked. It seems like
from the way you did your code, that when the form closes, it will
return a parameter, like some kind of closing status, which is stored
in the formResult object. I will look into the DialogResult
class/object to understand it a bit better, but I think this will do
it. Thanks! If it still gives me trouble, I'll get back to you, if you
don't mind. Thanks again.

Nov 17 '05 #6
Thanks for the reply - but that went right over my head. Its a bit over
my knowledge level right now. I have read about these things and
kind-of get it but the lingo in that post it tying too many of those
upper level concept around and I can't put it together. Hopefully that
will change soon ;)

Nov 17 '05 #7

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...
13
by: Craig | last post by:
Hey all, Here's the situation: - two websites, one on domain1 and the other on domain2 - domain1 opens a new window which is a javascript app from domain2 - domain1 needs to communicate with...
4
by: ReMEn | last post by:
How can I call a function located in Form1 while in the scope of Form2? I've tried Form1.MyFunction() but I get a compile errors. Any ideas? Thanks.
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...
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 ...
1
by: TGF | last post by:
Hello, I have a little dilemma (At least it is to me). I have two classes, Class A and class B, where Class A contains the UI thread and class B contains another thread. I want to be able to...
3
by: Mike Grainger | last post by:
Good Day: I am attempting to reference the value in a dropdownlist in the contents frame from the main frame and use it for filtering od a dataview. I get object is null. Any help on...
6
by: PaulN | last post by:
I need to instantiate a class (Class1) in the startup form (Form1), set some of Class1's properties then open another form (Form2) and have it read Class1's properties and set the remainder of...
2
by: Jasper Jones | last post by:
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...
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...
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
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
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.