CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14

Thread: Changing Views?

  1. #1
    Join Date
    Feb 2005
    Location
    Canada
    Posts
    204

    Changing Views?

    Ok so im new to Windows Programming so if i word this wrong or this is really a simple question I apologize. Everywhere I turn people get confused or I cant find an answer.

    Ok so right now I have my application like so


    File Options1 Options2
    ---------------------------------------------------

    display stuff


    ---------------------------------------------------

    Now basically its a form with a menu and the main page. Now when they click in options 2 and select "Add user" I want the display information to be replaced by the Add user view. I hope this makes sense. Now I was going to just make another form, but then that means replicating the menu bar and thats a waste because id have to retype twice.

    So im looking for a way to switch the screens as a menu option is picked, do I do this via a new form or what?

    Thanks

  2. #2
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Changing Views?

    It's usual to do this sort of thing in a seperate dialog form.

    I.e. a form which you 'ShowDialog' on.

    It is possible to switch views as your suggesting - I'm not sure whether it's necessary to go to that level of complexity though.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  3. #3
    Join Date
    Feb 2005
    Location
    Canada
    Posts
    204

    Re: Changing Views?

    Darwen can you explain or show an example or something of the easy way then. I dont really understand seperate dialog forms? If the way im asking is too complex can you show me how I should do it?

    Thanks.

  4. #4
    Join Date
    Dec 2003
    Location
    http://map.search.ch/zuerich.en.html
    Posts
    1,074

    Re: Changing Views?

    Hi Ctwizzy,

    here's is another link to add to your collection: UI Patterns and Techniques
    Useful? Then click on (Rate This Post) at the top of this post.

  5. #5
    Join Date
    Feb 2005
    Location
    Canada
    Posts
    204

    Re: Changing Views?

    Yes this website is in my list allready thanks lol.

    Still looking for the solution to present different data from a different selection...

  6. #6
    Join Date
    Dec 2003
    Location
    http://map.search.ch/zuerich.en.html
    Posts
    1,074

    Re: Changing Views?

    Whether this is the way to go is another matter, it all depends on your other options.

    But, in direct answer to your request "I want the display information to be replaced by the Add user view"...

    Rather than a Form put the controls for display info and "add user view" into UserControls.

    You can then use a tabbed control in the main Form eg. Card Stack and place each user control on a separate tab.

    Or you can switch controls manually by adding all the user controls to your Form and setting the Visible property appropriately.
    Useful? Then click on (Rate This Post) at the top of this post.

  7. #7
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    1,355

    Re: Changing Views?

    Rather than a Form put the controls for display info and "add user view" into UserControls.
    Yes, I'm using that kind of "UserControls" and I have already 2 year expirience with it.
    From my expirience I can tell: it works perfect!

    Best regards,
    Krzemo.

  8. #8
    Join Date
    Feb 2005
    Location
    Canada
    Posts
    204

    Re: Changing Views?

    I am a C#, make that Windows Programming novice. I have heard of user controls, tho no idea how/when to use or how to make them change the view. Could you show me and example, or walk me through the steps. Or if there is a tutorial somewhere?

    Thanks

  9. #9
    Join Date
    Feb 2005
    Location
    Canada
    Posts
    204

    Re: Changing Views?

    Im using this example to learn user controls

    http://www.codeguru.com/forum/newrep...te=1&p=1091866

    problem is, it jumps steps. So I have created my user control is a userControlLibrary, then it says add the dll.

    Problem is it shows no way of creating this dll?

    So I have a user control with 2 labels and a timer on it which displays the date and time. I want to include this user Control on my main application, but I dont know how now, so if someone could help please.

    Also someone above said I can use user Controls to control which view is being shown to users. How would I go loading and unloading the user controls as a button is pressed??

    Thanks

  10. #10
    Join Date
    Feb 2005
    Location
    Canada
    Posts
    204

    Re: Changing Views?

    Ok I built the control, and then referenced the dll in the bin dir.
    So now I have my control working.

    Can anyone tell me how to hide and show controls?

  11. #11
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    1,355

    Re: Changing Views?

    MyControl.Visible=false;

  12. #12
    Join Date
    Feb 2005
    Location
    Canada
    Posts
    204

    Re: Changing Views?

    And this is the way I should be switching what information the user sees based on their selections?

  13. #13
    Join Date
    Dec 2003
    Location
    http://map.search.ch/zuerich.en.html
    Posts
    1,074

    Re: Changing Views?

    Which tools are you using to build your app? Notepad or VisualStudio?

    Building apps without a proper IDE will be painful. Here's a free one: SharpDevelop.

    And this is the way I should be switching what information the user sees based on their selections?
    It's one way. If you want consistency, simply look at how other existing apps work.
    Useful? Then click on (Rate This Post) at the top of this post.

  14. #14
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    1,355

    Re: Changing Views?

    And this is the way I should be switching what information the user sees based on their selections?
    Yes. As Norfy already mention it:
    You can then use a tabbed control in the main Form eg. Card Stack and place each user control on a separate tab.

    Or you can switch controls manually by adding all the user controls to your Form and setting the Visible property appropriately.
    So 1 of solution is to change Visible property of your controls placed in your form inside captured event (for ex: If user checked Checkbox than one of the controls will appear, if unchecked it will get hidden)

    2nd solution is to place controls on tabcontrol and change tabcontrol index.

    Hope it Helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured