Creating Wizards for Win Forms in C#

前端 未结 4 988
梦毁少年i
梦毁少年i 2021-01-07 01:24

Is there any framework or tutorial on how to create a wizard in C#. I need to provide the user a way to do a sequence of selections/user inputs. I thought Wizards would be a

相关标签:
4条回答
  • 2021-01-07 01:26

    I'm working on a brief article for CodeProject on a "poor man's wizard" that uses the standard WinForms TabControl as its "foundation" : but that won't be ready for a few weeks.

    But think about the advantages using the standard WinForms TabControl gives you :

    1. "less code" == "cheap" : it will handle all the "business" suggested by Manzoor Ahmed's comment above (swapping in and out a bunch of panels), with much less code.

    2. "no painting" == "less work" : it can be used without any special ownerdraw or painting code (the Simmons article on CodeProject cited by Jay Riggs above has some optional custom painting for gradients, but I have not examined that code in depth to see if it can be used without any custom drawing/painting). Note, of course, that Manzoor's suggestion would also not demand custom drawing/painting.

    3. flexibility in UI : you can show the Tabs, or hide them.

    Here's two ideas on how to start using the TabControl as a "wizard" :

    I : how to hide the Tabs themselves if you don't want them visible (assuming a TabControl named tabControl1 on a Form named Form1) :

    a. if you want to restore visibility of the Tabs : create a Form scoped variable of type Region, and in the Form Load event put the current Region of the TabControl into that variable :

    Region tabOriginalRegion;
    
    private void Form1_Load(object sender, EventArgs e)
    {
        tabOriginalRegion = tabControl1.Region;
    }
    

    b. add this to the Form Load event to hide the Tabs

    // hide the tabs
    tabControl1.Region = new Region(tabControl1.DisplayRectangle);
    

    II : once the tabs are hidden : then, obviously you'll put your own buttons on each tab page to control forward and back movement. if the tabs are visible, then you'll want to handle the TabControl's 'Selecting event : inside that Event handler you can use e.TabPage to get the "destination" Tab, and you can cancel navigation to that "destination" tab by setting e.Cancel = true.

    Hope this is useful.

    0 讨论(0)
  • 2021-01-07 01:28

    Try this

    C# Winforms Wizard — CodeGuru.com

    Alternatively, you can use panels too. Every time you move forward or backward, just change the panels.

    0 讨论(0)
  • 2021-01-07 01:41

    I've found the DevExpress XtraWizard control to be quite nice to work with

    0 讨论(0)
  • 2021-01-07 01:45

    I've used this one from CodeProject:

    Wizard Form Implementation

    Search CodeProject for other wizards.

    0 讨论(0)
提交回复
热议问题