0

I want to know know if winform Form control can be loaded in Tablelayoutpanel control. If, yes how?

I have a tablelayoutpanel with two columns and one row. One column(that is cell 0,0) is filled with button control and the other column(cell 0,1) is empty.

I want to be able to load and display a borderless form in the cell 0,1 and the user clicks on a button.

Thanks in advance for your help

TaW
  • 53,122
  • 8
  • 69
  • 111
Paul Aziz
  • 11
  • 3
  • 2
    You should use a UserControl instead. – SLaks Jul 09 '17 at 13:38
  • Not really. A Form is a 'top-level' element and can't be added to a Controls collection. There are workarounds but this not recommended. To reuse or move around a collection of control place them in a UserControl and then put it on a Form, a TabPage or any other container control.. - Why exactly do you want to do this? Your question doesn't explain it well; atm it look like an x-y-problem.. – TaW Jul 09 '17 at 14:14
  • I am working on a project that uses singleton approach. The form has one TableLayoutPanel with two columns. On the left column I have a row of buttons. What I want to implement is this:When I click on a button on the left column, data which I will pull from database should loaded into the right column (content area) very much like outlook. The content areas will also include buttons to manipulate the data. I thought I could achieve this by creating a borderless forms and load the appropriate form directly into them content area. – Paul Aziz Jul 10 '17 at 23:26

1 Answers1

0

Usually you would use a usercontrol to achive this (like SLaks is pointing out). However you can alter the TopLevel property of the form. This way a control can be the parent of the form. About TopLevel property.

Example :

frmSubTest sFrm = new frmSubTest();
sFrm.FormBorderStyle = FormBorderStyle.None;
sFrm.Dock = DockStyle.Fill;
sFrm.TopLevel = false;
sFrm.Show();         
panel1.Controls.Add(sFrm); //Regular panel
TDull
  • 753
  • 5
  • 12