FormもControlの一つなので貼り付けられますよ。
var f = new Form2(this);
f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
f.TopLevel = false;
f.Location = new Point(0, 0);
f.Show();
this.Controls.Add(f);
1//Form1.cs2public partial class Form1 : Form
3{4 public Form1()5{6InitializeComponent();7 this.Load += new System.EventHandler(Form1_Load);8}910 private voidForm1_Load(object sender, EventArgs e)11{12Next(typeof(UserControl1));13}1415 public voidNext(Type t)16{17if(t == null)18{19Close();return;20}else{21 this.Controls.Clear();22 var uc = Activator.CreateInstance(t) as UserControl;23 this.Controls.Add(uc);24}25}26}
C#
1//UserControl1.cs2public partial class UserControl1 : UserControl
3{4 private System.Windows.Forms.Button button1;56 public UserControl1()7{8InitializeComponent();910 this.button1 = new System.Windows.Forms.Button();11 this.SuspendLayout();12 this.button1.Location = new System.Drawing.Point(110,145);13 this.button1.Name ="button1";14 this.button1.Size = new System.Drawing.Size(75,23);15 this.button1.TabIndex =0;16 this.button1.Text ="next";17 this.button1.UseVisualStyleBackColor = true;18 this.button1.Click += new System.EventHandler(this.button1_Click);19 this.AutoScaleDimensions = new System.Drawing.SizeF(6F,12F);20 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;21 this.BackColor = System.Drawing.Color.Red;22 this.Controls.Add(this.button1);23 this.Name ="UserControl1";24 this.Size = new System.Drawing.Size(300,300);25 this.ResumeLayout(false);26}2728 private voidbutton1_Click(object sender, EventArgs e)29{30(Parent as Form1).Next(typeof(UserControl2));31}32}
C#
1//UserControl2.cs2public partial class UserControl2 : UserControl
3{4 private System.Windows.Forms.Button button1;5 private System.Windows.Forms.Button button2;67 public UserControl2()8{9InitializeComponent();1011 this.button1 = new System.Windows.Forms.Button();12 this.button2 = new System.Windows.Forms.Button();13 this.SuspendLayout();14 this.button1.Location = new System.Drawing.Point(65,136);15 this.button1.Name ="button1";16 this.button1.Size = new System.Drawing.Size(75,23);17 this.button1.TabIndex =0;18 this.button1.Text ="next";19 this.button1.UseVisualStyleBackColor = true;20 this.button1.Click += new System.EventHandler(this.button1_Click);21 this.button2.Location = new System.Drawing.Point(146,136);22 this.button2.Name ="button2";23 this.button2.Size = new System.Drawing.Size(75,23);24 this.button2.TabIndex =0;25 this.button2.Text ="close";26 this.button2.UseVisualStyleBackColor = true;27 this.button2.Click += new System.EventHandler(this.button2_Click);28 this.AutoScaleDimensions = new System.Drawing.SizeF(6F,12F);29 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;30 this.BackColor = System.Drawing.Color.Blue;31 this.Controls.Add(this.button2);32 this.Controls.Add(this.button1);33 this.Name ="UserControl2";34 this.Size = new System.Drawing.Size(300,300);35 this.ResumeLayout(false);36}3738 private voidbutton1_Click(object sender, EventArgs e)39{40(Parent as Form1).Next(typeof(UserControl1));41}4243 private voidbutton2_Click(object sender, EventArgs e)44{45(Parent as Form1).Next(null);46}47}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/11/19 06:23
2015/11/19 06:30
2015/11/19 06:48
2015/11/19 06:50
2015/11/19 07:01
2015/11/19 07:18
2015/11/19 14:14