Newbie VB.NET question about forms

Discussion in 'Programming & Software Development' started by QuakeDude, Jan 21, 2008.

  1. QuakeDude

    QuakeDude ooooh weeee ooooh

    Joined:
    Aug 4, 2004
    Messages:
    8,515
    Location:
    Melbourne
    Guys,

    I'm looking at creating a VB.NET application to replace an existing Web-based app which is used to create/edit/delete Active Directory users, as I'm starting to hit the usual limits associated with Web-based applications.

    My question is this: what is the best method for creating the individual windows for each of the functions? The create user function (for example) goes through the following screens (ie, a new web page pops up for each step):
    1. Collect user details
    2. Confirm that the account isn't duplicate, suggest alternatives if it is
    3. Present AD tree and determine from the user which container the account will be created in
    4. If a template user was supplied, get the group membership from the template user and apply the same to the new one
    5. Confirm all details are correct with the operator before doing all the work

    Traditionally with VB6, I would have done this as an MDI application, with each of the ''functions" being an MDI child. Something like the new user function for example would probably be better off being a wizard, but my big concern is that the user might get lost having more than one MDI child open at any one time.

    What is the best way I can achieve this using VB.NET?
     
  2. Daft_Munt

    Daft_Munt Member

    Joined:
    Jan 23, 2003
    Messages:
    7,425
    Location:
    Hobart, The Federal Group
    Looks like someone will need to read up on the DirectoryServices Namespace in dotnet. I did something for creating new users...need to find that project, it would check to see if they exist before creation. When I find it I will let you know. There are lots of examples online, check out the MS dot net forums.

    Here is a place to start
    http://www.ondotnet.com/pub/a/dotnet/2003/07/28/activedir.html
     
    Last edited: Jan 23, 2008
  3. jezza323

    jezza323 Member

    Joined:
    Apr 7, 2005
    Messages:
    1,374
    Location:
    Brisbane
    you can create a program which launches each form in succession (like a wizard)

    just create a Main method in a class, and set this as the startup class instead of a form.

    all c# apps start this way, rather than the traditional VB form startup.
     
  4. Luke212

    Luke212 Member

    Joined:
    Feb 26, 2003
    Messages:
    10,013
    Location:
    Sydney
    its a normal wizard setup dood.

    create a welcome form
    when they click 'new' leave this welcome form open and open a wizard form on top. each time u click next, close the current form and open the next one in the series.

    pass your custom AD object between wizard forms to keep track of their creation.

    --------

    Welcome to AD Creator!!

    [Create new user...]
     
  5. scruff

    scruff RIP

    Joined:
    Jun 14, 2003
    Messages:
    3,442
    Location:
    Melbourne
    Create a form with a button "Create new user" on it.

    Create 5 forms, one for each step. Call them step1, step2, step3, step4, step5. Make sure that these forms have getters and setters so you can pass values from one form to the next

    Then, in your button1_click() function, do something like

    Code:
    public void button1_OnClick(object sender, EventArgs e)
    {
        Step1 s1 = new Step1();
        Step2 s2 = new Step2();
        Step3 s3 = new Step3();
        Step4 s4 = new Step4();
        Step5 s5 = new Step5();
    
        // Show step 1.
        s1.ShowDialog();
    
        // Show step 2
        s2.SomeValue = s1.PublicValue;
        s2.ShowDialog();
    
        // Show step 3
        s3.Value1 = s1.SomeRandomValue;
        s3.Value2 = s2.RandomInt;
        s3.ShowDialog();
    }
    
    Well, that's what I'd do, anyway.
     
  6. OP
    OP
    QuakeDude

    QuakeDude ooooh weeee ooooh

    Joined:
    Aug 4, 2004
    Messages:
    8,515
    Location:
    Melbourne
    Thanks guys - it looks like its a standard wizard-type set of forms after all. So my main form will be an MDI parent, as I will need to pull up edit forms for users, etc, however, when I click on the new user function, I launch a wizzard effectively.... which could post the results of the process into an MDI child (for example).

    I know it was a bit of a basic question, but not having really coded anything yet in VB.NET (and being a VB6 veteran) I wanted to confirm that this was indeed the right way to go. I appreciate everyone's patience with such a basic question :)
     
  7. jezza323

    jezza323 Member

    Joined:
    Apr 7, 2005
    Messages:
    1,374
    Location:
    Brisbane
    i wouldnt use an MDI parent and children

    i would just use a stock standard form
     
  8. OP
    OP
    QuakeDude

    QuakeDude ooooh weeee ooooh

    Joined:
    Aug 4, 2004
    Messages:
    8,515
    Location:
    Melbourne
    So how do I present each individual form.. ie. Edit Users (which would pull up a search field and let you edit the users details), etc?

    I guess traditionally I would have done this in VB6 using MDI forms, which is why I'm trying to work out the proper way to do it in VB.NET:

    [​IMG]
     
  9. scruff

    scruff RIP

    Joined:
    Jun 14, 2003
    Messages:
    3,442
    Location:
    Melbourne
    I'm not sure why you'd use MDI for this in the first place??? :confused:

    One way to do it in .NET would be to have a tab control and put all your controls for a form in each section. You can hide the tab bar and switch tabs programatically.
     
  10. Elyzion

    Elyzion Member

    Joined:
    Oct 27, 2004
    Messages:
    7,449
    Location:
    Singapore
    Not sure why you need all thos emenu items.

    I would display a list of users. Select a user and then a set of options comes up below the grid. Active/Inactive (logical Delete), Edit.

    If you edit it opens a new form with their details.

    If you select Active/Inactive it just switchs their active status.

    If you hit Add it opens the same form you use for editing, except its empty and no ID is passed in so it will Insert instead of Update.
     
  11. OP
    OP
    QuakeDude

    QuakeDude ooooh weeee ooooh

    Joined:
    Aug 4, 2004
    Messages:
    8,515
    Location:
    Melbourne
    I was thinking the MDI path as thats how I probably would have done it back in VB 6. I like the Tab idea though, and thats pretty much the type of answer I was after, ie. what would be the best practice way of structuring an application within VB.NET for this type of functionality.

    The tool does user maintenance at the moment, however, there will be additional functionality added at a later stage. As all of the current functionality seems to be user centric, it makes sense to do something like what you've suggested (as well). The custom printer option simply allows you to run a function which presents the user with a list of printers from their site to which a helpdesk person can assign one as their default (bypassing a local citrix policy to set their default printer to a nominated printer for each site).

    The only thing that would need to be seperate to this is the add user functionality, but thats already covered by using a wizard, as there are a number of steps involved to gather the appropriate information.
     
    Last edited: Jan 25, 2008
  12. jezza323

    jezza323 Member

    Joined:
    Apr 7, 2005
    Messages:
    1,374
    Location:
    Brisbane
    if you wanted to do it properly, do it like i said in my first post

    a seperate class controlling the data and the sequencing, launching the child forms in the correct sequence

    but there are many other ways to do it which are also correct, just probably not best practice ;)
     
  13. Bradzac

    Bradzac Member

    Joined:
    Aug 17, 2003
    Messages:
    1,744
    Sorry if I'm way off the mark here (cus I didn't really read the post and certainly none of the replies cus im lazy) but:

    Are you trying to do a step-by-step process? Much like a wizard? If so, can I recommend that you create each step in a custom control, and dynamically load the control when you need it? i.e. Form loads and inside it, it loads custom control #1. User fills out infomation required, the control is either hidden or disposed (your preference) and in it's place control #2 is shown. User continues etc until all steps are done. Controls are always loaded into the same form so there is no need for a popup or mdi interface.
     
  14. huckleberry

    huckleberry Member

    Joined:
    Feb 18, 2003
    Messages:
    673
    Location:
    Melbourne
    This kind of thing can be done quite neatly with panels. Panels would provide a similar look to tabs except you aren't stuck with the tab metaphor. Create a form with a panel that is used as a placeholder then create a number of child controls based on a panel the same size as the placeholder. Then simply swap them in and out of the place holder when needed.
     
  15. Jaffa_Cree

    Jaffa_Cree Member

    Joined:
    Feb 26, 2002
    Messages:
    1,976
    I agree with this method.
    Rather than creating a number of forms to serve each action, create those forms as user controls and load them into a panel control.
     
  16. Elyzion

    Elyzion Member

    Joined:
    Oct 27, 2004
    Messages:
    7,449
    Location:
    Singapore
    I disagree, from a development point of view this is painful if the Panels overlap in the design view and you swap visibility as you progress through the form.

    Theres no reason why you can't just make 1, 3, 5 or how ever many forms and after completing each one you just hide one and show the next.
     
  17. scruff

    scruff RIP

    Joined:
    Jun 14, 2003
    Messages:
    3,442
    Location:
    Melbourne
    This is why I suggested tabs :)
     
  18. Namheul

    Namheul Member

    Joined:
    Aug 18, 2003
    Messages:
    1,701
    Location:
    Victoria
    I would have used panels myself.

    Simply show them all at design-time so you can modify them, then when the form loads, show the default one and resize the form.

    Then to move to the next one, call a function that will show the next one, and hide the rest.
     
  19. Elyzion

    Elyzion Member

    Joined:
    Oct 27, 2004
    Messages:
    7,449
    Location:
    Singapore
    Yeah you see i don't see how that is more practical than just hiding/showing a new form each time.

    Its a lot easier to maintain since you have far less code to deal with when debugging. If you were doing it in 1 form. You have a lot to step through...

    If you have multiply forms, you have far less code to manage and debuggnig is a lot easier. It also means you can easily add more forms, take forms out, or add new bits n pieces a lot easier.
     
  20. Jaffa_Cree

    Jaffa_Cree Member

    Joined:
    Feb 26, 2002
    Messages:
    1,976
    I do not see the so called painful exercise you are trying to point out.
    You have 1 form that has a container like a panel. Dependig on the user action or what step they are up to you would load the user control into the panel. As they progress you can either hide/show/new/dispose it and show the next user control.

    The only issue with design time development is for some one who is not use to using user controls will be stumped when they open the form to find it empty.

    Using the controls + panel gives the UI a nice look, free from multiple windows overlapping and promotes a very clean look where there is only 1 parent form.

    I agree, there is no reason why you can not use X number of forms.
    Every suggestion pointed out thus far would work, it is just a matter of preference that I prefer a single form as a container where you load user controls into it opposed to numerous forms.
     
    Last edited: Jan 31, 2008

Share This Page

Advertisement: