C # with multiple screens Single Form

I created a GUI in C # that should look like this:

There are two buttons on the main screen when Button1 pressed. I do not want to open a new form with form2.show(); , but being in the same form, I want to change the display.

I did this using hidden GUI elements and showing other elements as needed.

It works fine as I wanted, but in the designer of View Form1 I had to create a dirty GUI.

My question is, is this a good programming practice or not? If not, what is the best or recommended way to achieve this.

thanks

+4
source share
3 answers

You might want to consider the "No tables" tab control, I try to use them for most of my work these days, as itโ€™s easy and quick to build an interface using the win-forms constructor with them.

  class TablessTabControl : TabControl { protected override void WndProc(ref Message m) { // Hide tabs by trapping the TCM_ADJUSTRECT message if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1; else base.WndProc(ref m); } } 

This will expand the tab control and hide the tabs at the top, then you can programmatically change the tab using code similar to the following:

  tablessTabControl.SelectTab("tabName"); 

This is not my original work, I found that she was floating on the network some time ago and could not remember where I saw her. Anyway, I hope this helps!

+7
source

how about using TabControl, you get all the โ€œlooksโ€ you want, without the useless visible = true/false shizzle.

+1
source

You can create different child controls View1 and View2 and show / hide each control depending on the state of the form and button clicks.

+1
source

All Articles