Creating Wizards for Windows Forms in C#

后端 未结 3 1103
野性不改
野性不改 2020-11-22 08:49

I am new in Creating Wizards for Windows Forms Application in C# .Net. So i don\'t have any idea in wizard creation. Please give me some ideas about creating Multiple wizard

3条回答
  •  鱼传尺愫
    2020-11-22 09:08

    Lots of ways to do it. Creating a form for each wizard step is possible, but very awkward. And ugly, lots of flickering when the user changes the step. Making each step a UserControl can work, you simply switch them in and out of the form's Controls collection. Or make one of them Visible = true for each step. The UC design tends to get convoluted though, you have to add public properties for each UI item.

    The easy and RAD way is to use a TabControl. Works very well in the designer since it allows you to switch tabs at design time and drop controls on each tab. Switching steps is trivial, just change the SelectedIndex property. The only thing non-trivial is to hide the tabs at runtime. Still easy to do by processing a Windows message. Add a new class to your form and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form.

    using System;
    using System.Windows.Forms;
    
    class WizardPages : TabControl {
      protected override void WndProc(ref Message m) {
        // Hide tabs by trapping the TCM_ADJUSTRECT message
        if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1;
        else base.WndProc(ref m);
      }
    }
    

提交回复
热议问题