<p>I'm rewriting an old application and use this as a good opportunity to try out C# and .NET development (I usually do a lot of plug-in stuff in C).</p>

<p>The application is basically a timer collecting data. It has a start view with a button to start the measurement. During the measurement the app has five different views depending on what information the user wants to see.</p>

<p>What is the best practice to switch between the views?
From start to running?
Between the running views?</p>

<p>Ideas:</p>

<ul>
<li>Use one form and hide and show controls</li>
<li>Use one start form and then a form with a TabControl</li>
<li>Use six separate forms</li>
</ul>

[{'answer_id': 25170, 'author': 'Adam Haile', 'author_id': 194, 'author_profile': 'https://Stackoverflow.com/users/194', 'pm_score': 2, 'selected': False, 'text': '<p>Tabbed forms are usually good... but only if you want the user to be able to see any view at any time... and it sounds like you might not.</p>\n\n<p>Separate forms definitely works, but you need to make sure that the switch is seemless...if you make sure the new form appears the same exact size and location of the old form, it will look like it thew same for with changing controls.</p>\n\n<p>The method I often use is actually to pre-setup all my controls on individual "Panel" controls and then show and hide these panels as I need them.  The "Panel" control is basically a control container... you can move the panel and all controls on it move relative.  And if you show or hide the panel, the controls on it do the same.  They are great for situations like this.</p>\n'}, {'answer_id': 25469, 'author': 'Brian Ensink', 'author_id': 1254, 'author_profile': 'https://Stackoverflow.com/users/1254', 'pm_score': 1, 'selected': False, 'text': '<blockquote>\n  <p>The method I often use is actually to\n  pre-setup all my controls on\n  individual "Panel" controls and then\n  show and hide these panels as I need\n  them.</p>\n</blockquote>\n\n<p>Instead of making each view a panel within a single form you could make each view a UserControl.  Then create a single form and write code to create and display the correct UserControl in the Form and to switch from one to the next.  This would be easier to maintain because you will have a separate class for each view instead of a single Form class with 6 panels each with their own controls -- that seems difficult and error prone to maintain.</p>\n'}, {'answer_id': 25512, 'author': 'Chris Karcher', 'author_id': 2773, 'author_profile': 'https://Stackoverflow.com/users/2773', 'pm_score': 4, 'selected': True, 'text': '<p>Creating a bunch of overlaid panels is a design-time nightmare.</p>\n\n<p>I would suggest using a tab control with each "view" on a separate tab, and then picking the correct tab at runtime.  You can avoid showing the tab headers by putting something like this in your form\'s Load event:</p>\n\n<pre><code>tabControl1.Top = tabControl1.Top - tabControl1.ItemSize.Height;\ntabControl1.Height = tabControl1.Height + tabControl1.ItemSize.Height;\ntabControl1.Region = new Region(new RectangleF(tabPage1.Left, tabPage1.Top, tabPage1.Width, tabPage1.Height + tabControl1.ItemSize.Height));\n</code></pre>\n'}, {'answer_id': 121939, 'author': 'ArielBH', 'author_id': 11659, 'author_profile': 'https://Stackoverflow.com/users/11659', 'pm_score': 0, 'selected': False, 'text': '<p>I would also check out <a href="http://msdn.microsoft.com/en-us/library/cc707819.aspx" rel="nofollow noreferrer">Composite Application Guidance for WPF</a> or <a href="http://msdn.microsoft.com/en-us/library/aa480450.aspx" rel="nofollow noreferrer">Smart Client Software Factory</a> </p>\n'}, {'answer_id': 122186, 'author': 'Hath', 'author_id': 5186, 'author_profile': 'https://Stackoverflow.com/users/5186', 'pm_score': 3, 'selected': False, 'text': "<p>What I do is to have a Panel where your different views will sit on the main form.\nthen create user controls for your different views. </p>\n\n<p>Then when I want to switch between a'view' you dock it to Panel on the main form.. code looks a little like this.</p>\n\n<p>i preffer this because you can then reuse your views, like if you want to open up a view in a tab you can dock your user controls inside tab pages.. or even inherit from \ntabpage instead of usercontrol to make things a bit more generic</p>\n\n<pre><code>public partial class MainForm : Form\n{\n    public enum FormViews\n    {\n        A, B\n    }\n    private MyViewA viewA; //user control with view a on it \n    private MyViewB viewB; //user control with view b on it\n\n    private FormViews _formView;\n    public FormViews FormView\n    {\n        get\n        {\n            return _formView;\n        }\n        set\n        {\n            _formView = value;\n            OnFormViewChanged(_formView);\n        }\n    }\n    protected virtual void OnFormViewChanged(FormViews view)\n    {\n        //contentPanel is just a System.Windows.Forms.Panel docked to fill the form\n        switch (view)\n        {\n            case FormViews.A:\n                if (viewA != null) viewA = new MyViewA();\n                //extension method, you could use a static function.\n                this.contentPanel.DockControl(viewA); \n                break;\n            case FormViews.B:\n                if (viewB != null) viewB = new MyViewB();\n                this.contentPanel.DockControl(viewB);\n                break;\n        }\n    }\n\n    public MainForm()\n    {\n\n        InitializeComponent();\n        FormView = FormViews.A; //simply change views like this\n    }\n}\n\npublic static class PanelExtensions\n{\n    public static void DockControl(this Panel thisControl, Control controlToDock)\n    {\n        thisControl.Controls.Clear();\n        thisControl.Controls.Add(controlToDock);\n        controlToDock.Dock = DockStyle.Fill;\n    }\n}\n</code></pre>\n"}]
['https://Stackoverflow.com/questions/25158', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2703/']