0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

cscの作法 その330

Last updated at Posted at 2023-06-03

概要

cscの作法、調べてみた。
練習問題、やってみた。

練習問題

MDIコンテナを実装せよ。

写真

image.png

サンプルコード

using System;
using System.IO;
using System.Windows.Forms;
using System.Drawing;

namespace App
{
	public partial class formSub: Form {
		TextBox bo1;
		public formMain fm;
		public formSub() {
			Text = "formSub";
			ClientSize = new Size(300, 200);
			bo1 = new TextBox();
			bo1.Location = new Point(50, 20);
			bo1.Text = "test desu";
			bo1.Size = new Size(100, 20);
			Controls.AddRange(new Control[] {
				bo1
			});
			Button btn1 = new Button();
			btn1.Location = new Point(50, 100);
			btn1.Text = "test";
			btn1.Click += btn1_Click;
			Controls.AddRange(new Control[] {
				btn1
			});
		}
		void btn1_Click(object sender, System.EventArgs e) {
			if (fm != null)
			{
				fm.ReceiveData = bo1.Text;
			}
		}
	}
	public partial class formMain: Form {
		public string ReceiveData {
			set {
				receiveData = value;
				bo1.Text = receiveData;
			}
			get {
				return receiveData;
			}
		}
		TextBox bo1;
		private string receiveData = "";
		public formMain() {
			Text = "formMain";
			BackColor = Color.Azure;
			//ForeColor = Color.Blue;
			ClientSize = new Size(120, 500);
			bo1 = new TextBox();
			bo1.Location = new Point(10, 20);
			bo1.Size = new Size(100, 20);
			Controls.AddRange(new Control[] {
				bo1
			});
			Button btn1 = new Button();
			btn1.Location = new Point(10, 70);
			btn1.Text = "sub";
			btn1.Click += btn1_Click;
			Controls.AddRange(new Control[] {
				btn1
			});
			Button btn2 = new Button();
			btn2.Location = new Point(10, 470);
			btn2.Text = "exit";
			btn2.Click += btn2_Click;
			Controls.AddRange(new Control[] {
				btn2
			});
		}
		void btn1_Click(object sender, System.EventArgs e) {
			formSub sub = new formSub();
			sub.MdiParent = MdiParent;
			sub.fm = this;
			sub.Show();
		}
		void btn2_Click(object sender, System.EventArgs e) {
			Application.Exit();
		}
	}
	public partial class formMdi: Form {
		public formMdi() {
			Text = "formMdi";
			ClientSize = new Size(900, 550);
			IsMdiContainer = true;
			formMain ma = new formMain();
			ma.MdiParent = this;
			ma.Show();
		}
		[STAThread]
		public static void Main() {
			Application.Run(new formMdi());
		}
	}
}





以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?