using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Load += new EventHandler(Form1_Load);
}
Panel panel1;
TreeView treeView1;
Button button1;
void Form1_Load(object sender, EventArgs e)
{
treeView1 = new TreeView();
treeView1.Name = "treeView1";
treeView1.Dock = DockStyle.Fill;
this.Controls.Add(treeView1);
panel1 = new Panel();
panel1.Name = "panel1";
panel1.Dock = DockStyle.Bottom;
panel1.Height = 26;
this.Controls.Add(panel1);
button1 = new Button();
button1.Name = "button1";
button1.Text = "button1";
panel1.Controls.Add(button1);
this.Set();
this.SizeChanged += new EventHandler(Form1_SizeChanged);
}
void Set()
{
int bw = button1.Width / 2;
int bh = button1.Height /2;
int pw = panel1.ClientSize.Width / 2;
int ph = panel1.ClientSize.Height /2;
button1.Location = new Point(pw - bw, ph - bh);
}
void Form1_SizeChanged(object sender, EventArgs e)
{
this.Set();
}
}
}