views:

486

answers:

2

I am in the process of converting a ASP.Net Web App to a C# WinForm App. I am struggling converting a specific page. This page is a questionnaire where each answer(usually rdo) determines what the next question will be.

I originally had thought to just have all questions displayed and set the read-only property accordingly. Unfortunately there are far to many questions for that to work as I absolutely want to avoid making the end user have to scroll.

Then I thought I might group the changing questions onto panels and set the visible flag appropriately. This is working but it is quickly becoming a nightmare for "the next guy."

Next, I thought I could create a collection of all the question controls and build the form as they answer dynamically.

  • Is this a good idea?

  • How would I go about that?

  • ICollection?

  • Alternatively, am I over thinking this (a common problem) and there is a much simpler solution?

  • Do you need more detail first?


Thank You and Have a blessed day!

+2  A: 

How about creating a "question template" as a user control with labels, radio buttons, etc, and giving it properties like the text for the question and a list of selectable answers? That would simplify the work of dynamically constructing the form when you add each question. That's not a complete answer, I understand, but it might be a jumping-off point.

JMD
+1. Thank you! I didn't ask this question but I'll be using this suggestion.
David Stratton
+1  A: 

I would describe this state machine (that's what it is) in some format like XML, and then autogenerate WinForms code from that. As for the actual UI approach, one way to go is use a tab control - make several tab pages (without headers, of course), and fill each page with the content related to your question. Then, just add navigation logic that's wired to your state machine. That's it!

Dmitri Nesteruk