0

I am making a project inside of Visual Studio 2019 with the language C#. I've been looking for an answer to this question for quite some time.

What I am trying to achieve: There will be multiple tabs across the side of a panel, when a button is pressed it will display another page inside of a specific area, instead of needing to show a whole different other form. I've tried using tabs but the buttons are not customizable nor can I arrange the position of each button individually.

Thank you and I hope somebody can help.

TaW
  • 53,122
  • 8
  • 69
  • 111
FIVEPZ
  • 1
  • 1
  • Are you looking something like this: https://stackoverflow.com/questions/17962341/how-to-load-form-inside-panel-other-form-in-win-app ? – ggeorge Feb 27 '21 at 08:39
  • 1
    If this is Windows Forms, please add a "winforms" tag. There are so many UI frameworks and the answer depends on which you use. – Klaus Gütter Feb 27 '21 at 08:50
  • 1
    If you don't TabPages in a Tab you can still achieve the same effect using buttons of your own and __UserControls__. These are like Forms but meant to be nested in some container, like in a Panel. Like a Form they can be reused, are classes of their own and are created as parioal classes.. Just make sure to create suitable interfaces to share/exchange data and/or events.. – TaW Feb 27 '21 at 09:04

1 Answers1

-1

I have answered the same from this thread How can I open multiple forms inside a form

You can generate a form inside a panel. By doing this below.

private void button1_Click(object sender, EventArgs e)
{
    Form2 frm = new Form2() { TopLevel = false, TopMost = true };
    frm.FormBorderStyle = FormBorderStyle.Sizable;
    this.pContainer.Controls.Add(frm);
    frm.Show();
}

For you to know more about this with video guide just check this website.

https://foxlearn.com/windows-forms/how-to-add-the-form-in-panel-from-another-form-in-csharp-442.html

pContainer is a panel control. Btw Topmost is optional depending on how you use it.

psy
  • 48
  • 5
  • There doesn't seem to be anything named pContainer or Panel Control, is there a package to install? – FIVEPZ Feb 27 '21 at 09:20
  • If you really really want to use a Form as a UserControl, don't set its borders. Also, setting `TopLevel = false, TopMost = true` is kind of pointless: `TopMost` is just cached and not set when `TopLevel = false`. Just `BringToFront()` it. UserControls also have a Designer, so... – Jimi Feb 27 '21 at 09:20
  • @FIVEPZ the pContainer is a panel Control. – psy Feb 27 '21 at 09:28
  • Despite the title OP doesn't really seem to want real forms just a better Tab control, so replacing TabPages by UserControl and coding the show/hide with his own buttons should do.. – TaW Feb 27 '21 at 09:35