Peter Duniho said:
What is your expectation of the behavior of the frmOrder instance when the
frmCustomer instance used to open it is closed? Can the single
frmCustomer instance change the customer it's displaying? Or is it in
turn opened from a form showing a list of customers, always showing the
same customer?
The answer to that is important with respect to how best to implement what
you're asking, because if the opened order form can only ever show one
customer's data, then you might as well just pass the CustomerID to the
frmOrder constructor. In that case, I would seriously consider making the
form modal also (i.e. use ShowDialog() instead of Show()). Otherwise, the
UI can get complicated, either with getting the forms out of synch or
having more than one frmOrder opened at a time without a clear indication
as to which other form it's associated with.
Alternatively, if the user can change the currently displayed user in the
frmCustomer form while the frmOrder is being displayed, then you'll want
to use a mechanism that allows for changing the filtering criteria while
the form is still open.
As for posting code, I'm happy to post some basic skeletal code (i.e.
leaving a lot of stuff out, including the specifics of updating the
DataGridView). But I'd like to know first the exact mechanism you expect
to use (based on the answers to the above).
I'm just going for the basic and the uncomplicated. The 2 forms, frmCustomer
& frmOrder, are only in sync when frmOrder is opened from frmCustomer using
CustomerID as the filter.
Form frmCustomer is the starting form of the application and is not opened
by any other form. The list of customers are in a comboBox control within
form frmCustomer which allows the user the only occasion to pick a particular
customer by CustomerName. This comboBox, cboCustomer, has CustomerName as
its "Display Member" and CustomerID as its "Value Member" properties.
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.