C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Tip: To make a control expand in the panel, please specify the Anchor property.
Note: The results indicate that a Button instance is found in Panel1 and a TextBox instance is found in Panel2.
Example that uses Panel1 and Panel2 on SplitContainer: C#
using System;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// Get information about Panel1 controls and Panel2 controls.
StringBuilder builder = new StringBuilder();
foreach (var control in splitContainer1.Panel1.Controls)
{
builder.Append("Panel1: ").AppendLine(control.GetType().ToString());
}
foreach (var control in splitContainer1.Panel2.Controls)
{
builder.Append("Panel2: ").AppendLine(control.GetType().ToString());
}
MessageBox.Show(builder.ToString());
}
}
}
Output
Panel1: System.Windows.Forms.Button
Panel2: System.Windows.Forms.TextBox
Tip: If you have to readjust parts of your program, or want to persist the position of the Splitter to disk, listen for this event.