开发者

How do I create a "wizard" style ui using vb.net?

The idea is that I would have a set of forms, users would click through a "forward" and "back" button, and the current form would change to a different one. My issue is that I can write code that just pops up a new form, but im not sure how to do a "replacement开发者_运维知识库" of my current form. How is this usually done?


What I did recently was to create a form with buttons already in place and a large panel to contain each step. The dialog would accept an initial step in the form of a IWizStep instance, and the things would roll from there.

Each step was a class exposing a UserControl responsible for the visual aspect of the step, while the logic itself was handled by the class (it was a little more complicated that that, but that was the general idea).

The IWizStep interface, implemented by the step and accepted by the dialog, was on the lines of:

    Interface IWizStep
      Event StateChanged As EventHandler 
      ReadOnly Property Control As Control
      ReadOnly Property Title As String
      ReadOnly Property CanMovePrevious As Boolean
      ReadOnly Property CanMoveNext As Boolean
      Function MovePrevious As IWizStep
      Function MoveNext As IWizStep
    End Interface

To put everything together, a controller class would know how to compose the steps necessary for each given action. Therefore I had a controller for, say, "Emit Order", which needed some 10 steps, and a controller for "Emit Orders in Batch", which needed only a couple of steps.


Create a set of UserControls, and add and remove them from a Panel in a single form. (and set Dock to Fill)


You could define a user control which acts as a "wizard". It just needs the buttons you have and an array of content panels, just have it switch through the panels when the buttons are pressed assuming a certain condition is met within the controls on the panel. There's no real definitive "wizard" maker, since it's pretty easy to roll your own wizard.

You don't need to do a "replacement" of your current form really, you could just add a new one to the project. If you do need to for whatever reason, just grab the control collection with Me.Controls, copy that somewhere, and put the new controls up. When you don't need the wizard, swap them out again. It's generally best practice to make a new form however!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜