saving mdi child forms contents

  • Thread starter Thread starter pcPirate
  • Start date Start date
P

pcPirate

Okay,

I've have a mdiparentform and only one mdichild form.

My parent form has a toolbar with only one button "Open Record". When a user
click on the button, a child form would be shown.

My child form retrieve a set of value from the MSSQL2K database and displays
them in textboxes. And the users are able to change the value and save them
(by clicking a save button) back to the database.

The problem is this. when the user click the "Open Record" toolbar button 2
times, there would be 2 child form come out (which is good). However, when
the user amend both details in the both child forms, the values are saved
correctly in second child form but not the first child form. This really
make me headache. I use a lot of static variable in the coding of making the
child form. Is this the problem or others?

Pls. advice.

pcPirate
 
Looks like that could be the problem. If you have a completely encapsulated
class, the two instances would be truly separate.

It should be pretty easy to figure out which variable is being overwritten
and modify your design to not share it.

Good luck!
-vJ
 
Thanks for your reply,

So, what you mean is that, I should put all the function into different
classes (or files) an call the function from the form class?

Pls. advice.
pcPirate
 
Not really. What I meant is, try not to make shared static members unless
you are absolutely sure you need them.

You still need only one class. And as long as you don't make any variable
static, you will not be over-writing any value by mistake.

-vJ
 
Thanks for you reply again,

However, I'm really badly needing the static members to make my project
works. That's becos' I need to call the static variable from class to class.
Or, is there any method which I don't need to use the static member and
still I could call the variable from class to class?

Pls. advice.

pcPirate.
 
You can still use static members - just make sure you're not treading on
each other instance's territory when you write them.

Unless I have some code snippets, I cannot provide much help on the design
issues.

-vJ
 
Back
Top