How to sycnc data in two form?

  • Thread starter Thread starter Jet Leung
  • Start date Start date
J

Jet Leung

Hi all,
I hade made a programme there are two forms, one is used for show the result
other one is used for add and delete items.After I add or delete items in
one form , and how to make other form which is use for show result to
reflash the result and get the real data?
 
Jet,

There are many ways to do this, but its hard to say what is best without
knowing your code.

You could create an event and hook into this on the other form. Raise the
event when your data changes and use the eventhanlder to refresh your other
form.

Alternatively just expose a public method on your child form and call this
from the parent form when the data changes.

Phil...
 
Have both forms reference a common dataset, bind the displayed fields and
have the currency manager do the work for you.
 
Hi Phil.
As you say, if I want to do this, I have to create an event and hook in
the result showing form , and raise the event in the other? Are there
any sample code to decript it?
 
Hi Colin,
How to have both froms reference a common dataset? What does your mean?
And where the currency manager placed in?
The result showing form or the result modify form? Any sample?
 
Have you main form/class create the dataset,
Create a DataView & DataSet on FormA and bind controls on FormA to DataView,
Create FormB and do the same as FormA,

From your main class pass the master DataSet to both forms, e.g. vFormA =
new FormA(MasterDataSet),
You constructor of FormA & FormB would be something like;
public FormA(DataSet pMasterDataSet)
{
InitializeComponent();
dataView1.DataTable = pMasterDataSet.Tables["Customer"];
}

Now both forms, DataViews & bound controls all point to the same DataSet.

- Colin
 
Thank a lot!
Yes, I had created dataset in my main form. As you say, you mean if I
want to sycnc the result in two form, I have to transfer the dataset
from one form to other form? And make both two controls bind the same
dataset?
 
Back
Top