Search code examples
c#winformsuser-interfacetabcontrolui-design

Master page in C#


I have to design a control_panel form. This will have many tabs. How should I design this? Should I make different new forms for each tab or is there a concept of Masterpage in C# WinForms?

Please give me your opinions. Thanks.


Solution

  • It's easy enough to whip up something like this in WinForms, using a TabControl, filled with several different TabPages, and a corresponding ImageList to hold the icons for each tab:

    Sample form with tabs

    Then you can just place the controls you want on each TabPage as you normally would. The designer has excellent built-in support for the TabControl, allowing you to simply click on the tab you want to switch to it as you could if your application was running. Here's a tutorial on implementing tabs in C#.

    If you need more extensibility and encapsulation than provided by adding individual controls to each TabPage, you can create a custom UserControl corresponding to each of your tabs, and then place an instance of that UserControl into the TabPage. I don't really know much about MasterPages, but creating a base UserControl that all of your other UserControls inherit off (and then add their unique elements) of seems like it would provide similar functionality.