I was wondering how you do this. Would you have to use delegates and event handlers or can you do it through application.Run(object) and call that in the clickevent but I need to keep a reference to previous form. but that doesn't seem possible.

Recommended Answers

All 4 Replies

Depending on how many forms you'll be working with and whether you want to maintain their state when moving between them, you could keep a List of the forms visited.
If you want to maintain their state then (eg values in controls, changes made, etc) and you are using relatively few forms you can hide each form after its used and keep a reference to it in a List<Form>. If you're talking HUNDREDS of different instances of forms it could suffer a bit from memory bloat that way though : /

You could use a single form with header (logo) and footer contains the wizard controls(e.g. NextBtn , BackBtn)

You can use the body area to show and hide panels according to the event and the state of the program.

You can use the wizard at the following link and customize to reach your needs
http://www.codeproject.com/KB/cs/WizardDemo.aspx

I suggest using 1 form and using a tabcontrol. but hide its tabs.

I just posted the same thing on that codeproject article. Because its way overkill the way they have done it.

here is an example of hiding them tabs at runtime, but not and design time.

using System;
using System.ComponentModel;
using System.Windows.Forms;

namespace customControls
{
  public class TabControlEx : TabControl
  {
    /// <summary>
    /// Gets or sets a value indicating whether the tab headers should be drawn
    /// </summary>
    [
    Description("Gets or sets a value indicating whether the tab headers should be drawn"),
    DefaultValue(true)
    ]
    public bool ShowTabHeaders { get; set; }

    public TabControlEx()
      : base()
    {
    }

    protected override void WndProc(ref Message m)
    {
      // Hide tabs by trapping the TCM_ADJUSTRECT message
      if (!ShowTabHeaders && m.Msg == 0x1328 && !DesignMode) 
        m.Result = (IntPtr)1;
      else
        base.WndProc(ref m);
    }
  }
}

All of the answers here have thier advantages and disadvantages. At the end of the day, it depends a lot on the size and scope of the project you are working on. If it is going to be a large scale application i would recommend using an MDI parent with a stack style history log (the way web browsers work). Each time you move from form to form you add it to the stack and then pop them off when you use the back button.
If its a small application with only a handful of forms then use either panels or tab control.
If you give us an outline of what your app will do we might be able to narrow it down for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.