• Advertisement
Sign in to follow this  

Visual Studio C#, Best way to implement many "GUI Panels"

This topic is 895 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I'm a little bit new to Visual Studio. I've had previous experience in Java Swing.

 

Whats the best way to implement a program which uses multiple "pages".

In Java I had multple panels which I would make them visible or non-visible (I used window builder).

 

Now on Visual Studio I use multiple forms for each "page" of my application.

Is this the right way to go?

I have also seen multiple panels in the same form, but they are not visible on the design view I think which makes them harder to work with.

TabControl looks very convenient way to manage pages, but I dont want my program to appear like it has tabs,

 

Is there an open source program which I can "steal" ideas from?

I want to know whats the most professional way to deal with GUI.

 

Thank you

Edited by shadowstep00

Share this post


Link to post
Share on other sites
Advertisement

There are an enormous number of options, really just about anything you can imagine.

 

On one extreme, you can build custom controls for each piece, then use those controls into bigger custom controls, and put those into other custom controls, until you have put together your entire window.

 

On another extreme, you can build the entire layout and custom draw everything in one pass in a single section of code.

 

Somewhere in the middle you can build individual panels and have them respond to events.

 

 

There are many GUI-builders that can help you out, including the built-in system in Visual Studio. 

 

There really isn't one single answer to what is "professional".  What is best in one situation may be terrible in another situation.

Share this post


Link to post
Share on other sites
UX design is a whole discipline in itself.

You're asking for help implementing a GUI layout you haven't decided on for a task we know nothing about. No one can possibly give you a meaningful answer to that (other than "we don't know").

Think about your users:
Who are they? Are they likely to be experts in their domain or novices? What is their likely familiarity with computers? Do you have one group of users or many (i.e. Some experts, some novices)?

What tasks are they trying to achieve with your software? What information does it need to convey? What is commonly used and must be easily accessible? What is potentially harmful and must be guarded against?

All these questions should lead you into a UX design. Draw it out on paper or in a software tool. Ask people to pretend they're using it and see how they respond.

Then start coding.

Share this post


Link to post
Share on other sites

First of all thank you for the replies,

 

My problem is not how to design the GUI on paper. I have decided pretty much how my GUI will be.

The problem I have right now is how to best handle the "pages" of my program (NOT in design, but programming wise inside Visual Studio).

 

For example when I press a button I want to get redirected to another "page" of the application. How should I implement that?

Should I redirect the user to another form? should I change the panel? should I use user control?

 

I want you to recommend me a basic easy way to manage and maintain those pages.

When I say easily manage I mean so that I can clearly see from the design view what the UI looks like. 

 

So far I haven't found a clear way how to handle multiple pages in an application.

Edited by shadowstep00

Share this post


Link to post
Share on other sites
Which kind of app are you making? WinForms? WPF?

I mainly use WinForms. In WinForms if I wanted to do this I would probably use multiple UserControls to use the designer interface more easily. UserControls can also be instantiated on the fly which allows you to create multiple instances of the same page if you ever need to. Creating UserControls on the fly and removing them once they're done being used also lets you make sure you never leave a page in a bad state like you might do with tab pages.

Share this post


Link to post
Share on other sites

I have Visual Studio 2015 Community.

I'm using windows form application (project).

I think the toolbox is enough for me to implement what I want.

EDIT: Nypyren gave me pretty much the answer which I was looking for. I would really appreciate if you could recommend me any tutorial where I can learn more about user controls.

Edited by shadowstep00

Share this post


Link to post
Share on other sites


My problem is not how to design the GUI on paper. I have decided pretty much how my GUI will be.

 

Honestly, it really doesn't sound like you have.


The problem I have right now is how to best handle the "pages" of my program (NOT in design, but programming wise inside Visual Studio).

"Pages" is not really a term used in desktop UI design (outside of Tab pages). It's much more of a web term. Desktop terms tend to be dialogs or forms.

 


For example when I press a button I want to get redirected to another "page" of the application. How should I implement that?
Should I redirect the user to another form? should I change the panel? should I use user control?

This is easy to do, but once again, it still sounds like you're unsure of your design. That's fine, nothing wrong with prototyping to see what works, but you need to think about your design in terms of process. Can your user do more than one thing at a time? Do you understand the concept of modal vs modeless dialogs?Do you want an MDI environment?

 


I want you to recommend me a basic easy way to manage and maintain those pages.
When I say easily manage I mean so that I can clearly see from the design view what the UI looks like. 

 

Is there some reason you can't use the standard winforms designer in Visual Studio? 

Share this post


Link to post
Share on other sites

I would really appreciate if you could recommend me any tutorial where I can learn more about user controls.


For the most part, you can think of UserControl as if it was halfway between a control like a Label/TextBox and a Form.

- You add them to an existing form or inside a panel or other container control.
- They don't have any of the Form-specific things like resizable border controls or minimize/maximize/close buttons.
- You can use the Forms Designer to put multiple controls inside them just like you can with a Form and set up tabbing, anchoring, docking, etc with the child controls.
- Each UserControl is a separate class, so you can encapsulate their members or expose them if you want, similar to how there's many different ways you can pass data between two Forms. Choose whatever works best for you.

You can Google search for "WinForms C# UserControl tutorial" for more in-depth tutorials.

For your specific case, what you would want to do is make your UserControls, and then have your form create them and then set userControlInstance.Dock = DockStyle.Fill; to make the user control automatically fill the entire form. Then design each UserControl so that the controls nested inside of it are anchored or docked properly within the UserControl.

To do inter-page navigation, have each UserControl's navigation buttons raise an event for your Form to handle, and have the Form switch between pages. You can encapsulate these events or expose the navigation buttons directly, depending on what your personal maintainability/rapid development biases are. Edited by Nypyren

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement