0

I am (still) writing a small application which requires me to use several windows forms to show to the user.

Some of the forms just show progress messages while the application performs tests using several external devices.

The forms will usually be used in order (see below) but there may be some errors picked up from the devices, in which case an Error Reporting form will be used. The user will have the option to go back to the beginning or to the 2nd test (the 1st test takes 30 mins to perform). The error report can be invoked from any other form.

Also, the final form has the option to go back to the beginning to perform the tests on a new device.

Obviously this would cause the suite of forms to get rather tangled up. if it were used for several devices with errors etc.

So am I have a few questions.

Am I using the forms correctly and if so, how do I pass control from one form to the next one without having to go back to the original form, if that makes sense ?

Can I still have access to all variables created in preceding forms, or should I create all the variables in the initial form setup ?

Or should I have all the processing within one parent form and simply "show" the other forms as part of the procedure ?

I hope this doesn't sound too stupid, but I havent used multiple forms in C# yet. The steps are ALSO dependent on each other.

The following is the usual flowchart of forms, with PRGERREP being called from any form (more or less).

PRGSTART
PRGDEFAULT
PRGTEST1
PRGTEST2
PRGTEST3
PRGTEST4
PRGMANUAL
PRGFINALE

PRGERREP 

Any help or advice would be most appreciated.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
George
  • 347
  • 2
  • 9
  • 21

3 Answers3

1

Please try to focus more on the question, not the context. Even though i don't know exactly what you want, you should check out MDI Applications.

Basically you have a parent form with several child forms. Should your tests be finished you can BringToFront() the corresponding child window from the parent form.

Johannes Rudolph
  • 35,298
  • 14
  • 114
  • 172
0

Consider inheriting from an ApplicationContext to implement this logic in your application. See here and here.

Community
  • 1
  • 1
Zev Spitz
  • 13,950
  • 6
  • 64
  • 136
0

I question the requirement to use multiple forms for this. Most applications show all information for a task; progress, tests, errors, messages, et al. in a single window, not multiple windows. Web browsers and office applications are very complex programs and manage to show all task information in a single window.

The fact that you are trying to "pass control" between multiple forms makes me suspect using multiple windows is a bad design. Look at the windows on your screen now; each one is a self-contained environment and does not need to "pass control" between each other.

If you are trying to make the user do something in sequence, handling errors before going on to the next step and allowing the user to "go back to the beginning", a wizard-like design may be better.

Create a single form with fields and buttons for the first task. Clicking a button redraws the form with fields and buttons for the next task, and buttons to go back or start over. This can be done more easily than creating a bunch of separate forms and trying to synchronize data between them.

Dour High Arch
  • 21,513
  • 29
  • 75
  • 90
  • Thanks for that. I dont think I put enough effort into the design of this as its not really a big application. I thought I would ned one form per step which I suppose it would need in a large and complicated application, using OOAD ? All of the middle steps can def use the same form, reset at each step to clear the previous steps messages. The first form needs input from the user, who needs to choose what type of device is to be tested, and for them to enter details such as serial number and name etc. – George Oct 11 '09 at 18:36
  • Then the app would go thru all the steps in sequence as we need to keep track of what state the devices are in to perform the relevant tests. Then at the end I need to present the user with an option to save and print the info off then do another test or exit. The Errorrep simply outputs a relevant message the option to start over again, start on step 2 or to exit. Can you change the look of the windows in the program ? The first window would have several input fields whereas the other windows would have a large message area in the same place also, how would you handle the varying buttons – George Oct 11 '09 at 18:40
  • What about moving around the app, going back to the begining, to step2 etc. can this be done easily in C# too ? – George Oct 11 '09 at 18:41
  • Also, as part of testing, I wanted to have a button on one of the windows where I could execute step1 then step2 etc, but then come back to the window after each step is complete so I can check where I am at. Is it easy to execute a block of code at a time ? – George Oct 11 '09 at 18:44
  • You should add this information to your question. All the things you describe can easily be done in C#. Which is the best way to implement them depends on your workflow, which we do not know. – Dour High Arch Oct 11 '09 at 23:39
  • One possible method is to design a single huge form with all the steps laid out horizontally in equal-sized panels. Then before you show the form, set the window size to that of a single panel. As the user fills out fields, set the form horizontal origin to each panel in turn, so only a few are displayed at once. This works for small sequences that do not change, and allows complete access to all controls in the sequence. – Dour High Arch Oct 11 '09 at 23:41