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

Link forms (newbie)

I am beginning C# programming and am trying to open frmOrders from a button
in frmCustomer (in Northwind database) with CustomerID as the link between
the two forms. What is the easiest and quickest way to do this? I'm stuck at:

private void btnOrders_Click(object sender, EventArgs e)
{
Form newForm = new frmOrders();

newForm.Show();
}

not able to figure out how to filter frmOrders to only show the focussed
CustomerID in frmCustomer.
Jun 27 '08 #1
4 1610
On Sun, 27 Apr 2008 08:33:00 -0700, JP <JP@discussions.microsoft.com
wrote:
I am beginning C# programming and am trying to open frmOrders from a
button
in frmCustomer (in Northwind database) with CustomerID as the link
between
the two forms. What is the easiest and quickest way to do this? I'm
stuck at:

private void btnOrders_Click(object sender, EventArgs e)
{
Form newForm = new frmOrders();

newForm.Show();
}

not able to figure out how to filter frmOrders to only show the focussed
CustomerID in frmCustomer.
It's hard to say without knowing how you've structured the code in each
form. However, if the "frmOrders" class is to take as a filter a
"CustomerID", then you will need a couple of things:

* Some API in the frmOrder class that allows the setting of the filter
(seeing as how the form isn't modal, I suspect simply passing the value to
the constructor isn't sufficient...you probably want a property and/or
method that allows you to specify a new CustomerID value as the user
selection changes in the other form, as well as possibly allowing for
clearing the filtering altogether, if that's possible)

* The frmCustomer class will need to save the reference to the form
it's created and shown, so that as the user selection in the frmCustomer
form changes, it can then call the frmOrder API (see above) with the
appropriate CustomerID value to change the filtering. So rather than
assigning the new form instance to a local variable in your Click event
handler, you'll want a class instance member to which you can assign the
instance reference, so that you can get it later when the user changes the
selected customer.

Pete
Jun 27 '08 #2
Thanks for the suggestions. I'm at the step-by-step learning stage. Could you
be kind enough to show the coding?

"Peter Duniho" wrote:
On Sun, 27 Apr 2008 08:33:00 -0700, JP <JP@discussions.microsoft.com>
wrote:
I am beginning C# programming and am trying to open frmOrders from a
button
in frmCustomer (in Northwind database) with CustomerID as the link
between
the two forms. What is the easiest and quickest way to do this? I'm
stuck at:

private void btnOrders_Click(object sender, EventArgs e)
{
Form newForm = new frmOrders();

newForm.Show();
}

not able to figure out how to filter frmOrders to only show the focussed
CustomerID in frmCustomer.

It's hard to say without knowing how you've structured the code in each
form. However, if the "frmOrders" class is to take as a filter a
"CustomerID", then you will need a couple of things:

* Some API in the frmOrder class that allows the setting of the filter
(seeing as how the form isn't modal, I suspect simply passing the value to
the constructor isn't sufficient...you probably want a property and/or
method that allows you to specify a new CustomerID value as the user
selection changes in the other form, as well as possibly allowing for
clearing the filtering altogether, if that's possible)

* The frmCustomer class will need to save the reference to the form
it's created and shown, so that as the user selection in the frmCustomer
form changes, it can then call the frmOrder API (see above) with the
appropriate CustomerID value to change the filtering. So rather than
assigning the new form instance to a local variable in your Click event
handler, you'll want a class instance member to which you can assign the
instance reference, so that you can get it later when the user changes the
selected customer.

Pete
Jun 27 '08 #3
frmCustomer is a simple form showing information of one customer. It has a
comboBox to search for a customer. It has a button, btnOrders, which opens
the form frmOrders. frmOrders has one dataGridView showing the Orders table.
Customer table (represented in frmCustomer) is related to Orders table
(represented in frmOrders) in a one-to-many relationship.

At frmCustomer, when a particular customer is selected, I would like to be
able to see only all of that particular customer's Orders in the frmOrder's
dataGridView when I open frmOrder.

"Peter Duniho" wrote:
On Sun, 27 Apr 2008 08:33:00 -0700, JP <JP@discussions.microsoft.com>
wrote:
I am beginning C# programming and am trying to open frmOrders from a
button
in frmCustomer (in Northwind database) with CustomerID as the link
between
the two forms. What is the easiest and quickest way to do this? I'm
stuck at:

private void btnOrders_Click(object sender, EventArgs e)
{
Form newForm = new frmOrders();

newForm.Show();
}

not able to figure out how to filter frmOrders to only show the focussed
CustomerID in frmCustomer.

It's hard to say without knowing how you've structured the code in each
form. However, if the "frmOrders" class is to take as a filter a
"CustomerID", then you will need a couple of things:

* Some API in the frmOrder class that allows the setting of the filter
(seeing as how the form isn't modal, I suspect simply passing the value to
the constructor isn't sufficient...you probably want a property and/or
method that allows you to specify a new CustomerID value as the user
selection changes in the other form, as well as possibly allowing for
clearing the filtering altogether, if that's possible)

* The frmCustomer class will need to save the reference to the form
it's created and shown, so that as the user selection in the frmCustomer
form changes, it can then call the frmOrder API (see above) with the
appropriate CustomerID value to change the filtering. So rather than
assigning the new form instance to a local variable in your Click event
handler, you'll want a class instance member to which you can assign the
instance reference, so that you can get it later when the user changes the
selected customer.

Pete
Jun 27 '08 #4
On Mon, 28 Apr 2008 02:20:01 -0700, JP <JP@discussions.microsoft.com
wrote:
[...]
Passing the CustomerID from frmCustomer to the frmOrder constructer
sounds
like the way to go. What's the coding to do this? Just the basic skeletal
code will do. Thanks again.
class frmOrder
{
public frmOrder(CustomerID id)
{
// use "id" to prepare filtering as appropriate
}
}

Then when creating the form:

frmOrder form = new frmOrder(currentID);

where the variable "currentID" is whatever the current customer ID is (you
may find that you can just get this directly from the ComboBox control,
depending on your exact implementation).

For what it's worth, if the description "pass the CustomerID to the
frmOrder constructor" isn't sufficient for you to understand that the
above is what I mean, you may want to review your basic OOP techniques
before proceeeding. That wasn't exactly an esoteric technique I was
describing. :)

Pete
Jun 27 '08 #5

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

Similar topics

4
by: Newbie | last post by:
Is it possible to set up an event handler or something else so that when *any* link on the page is clicked it 'fires-up', executes some JS and then continues to process the link that was clicked?...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
14
by: Steve McLellan | last post by:
Hi, Sorry to repost, but this is becoming aggravating, and causing me a lot of wasted time. I've got a reasonably large mixed C++ project, and after a number of builds (but not a constant...
2
by: Mr Newbie | last post by:
I am writing an application in which I have configured Forms Authentication. However, it never seems to time out. I thought the default was twenty minutes. I am wondering if the Persisatnt...
2
by: Pink | last post by:
Hi I am a Newbie to .Net can anyone let me know the diffrence between Windows.Forms and Winforms they are different version of totally different and are some methods different too Thanks
7
by: AdeelAlvi | last post by:
iam working on a project called service desk that automates the departmental services online .one major component i have to create is that to convert paper based forms into dynamic webforms . i...
7
by: Lisa | last post by:
I have an Access 2000 application that uses the following function to re-link my tables when I switch from my Current back end to a Dummy back end. I also use it to refresh my links. Function...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
2
by: shreeks | last post by:
I am newbie working on Access. I am asked to create a new database screen with "Letter Variables" as the field name. Letter variables is a radio button with Yes and No fields. If an Yes radio...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.