110,570
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication59
{
public partial class Form1 : Form
{
Panel P = new Panel();
public Form1()
{
InitializeComponent();
this.Size = new Size(600, 600);
P.Size = new Size(200, 200);
P.Location = new Point(0, 100);
P.Parent = this;
Form Form2 = new Form();
Form2.TopLevel = false;
Form2.Parent = P;
Form2.BackColor = Color.Black;
Form2.Size = P.Size;
Form2.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
Form2.Show();
Button B1 = new Button();
B1.Parent = this;
B1.Text = "放大panel";
B1.Click += new EventHandler(B1_Click);
Button B2 = new Button();
B2.Parent = this;
B2.Text = "缩小panel";
B2.Click += new EventHandler(B2_Click);
B2.Location = new Point(0, 50);
}
void B1_Click(object sender, EventArgs e)
{
P.Size = Size.Add(P.Size, new Size(100, 100));
}
void B2_Click(object sender, EventArgs e)
{
P.Size = Size.Subtract(P.Size, new Size(100, 100));
}
}
}