Home > Software engineering >  Combining two programs in one without new form - c#
Combining two programs in one without new form - c#

Time:08-17

I am doing my first steps programming a little toolbox in C#.

I want to choose the program to run via a menustrip. How can I switch all visible textboxes, buttons etc. on the same form? I don't want to open a new form. Do I have to show/hide every element "by hand" or is there a better solution?

I hope you get my problem. Thanks in advance.

CodePudding user response:

Yes totally understood. You need a way to navigate between different fragments within your application.

Since these are your first steps and not a legacy app, why aren't you starting with WPF which is the successor of Winforms ? (newer better)

See how can you achieve such functionally in WPF

https://docs.microsoft.com/en-us/dotnet/desktop/wpf/app-development/navigation-overview?view=netframeworkdesktop-4.8

Although the terms are similar and also apply in winforms.

CodePudding user response:

What you want to do is to create all the buttons etc as part of a UserControl. You can then add your custom UserControl to the form. This should allow you to switch the user control for some other control, or change the visibility for the whole user control.

This can also allow you to place multiple user controls side by side or in some other layout.

  • Related