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の作法 その474

Posted at

概要

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

練習問題

tabcontrolを、使え。

方針

  • ToDoアプリを作る。
  • 動的に、TabPageを作る。

写真

image.png

サンプルコード

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

class SampleForm: Form {
	TextBox bo0;
	TabControl tabc;
	int i = 0;
	SampleForm() {
		ClientSize = new Size(400, 200);
		Text = "To Do";
		Label la0 = new Label();
		la0.Location = new Point(50, 10);
		la0.Text = "To Do";
		bo0 = new TextBox();
		bo0.Location = new Point(150, 10);
		bo0.Text = "金持ちになる";
		Button btn1 = new Button();
		btn1.Location = new Point(150, 50);
		btn1.Text = "登録";
		btn1.Click += btn1_Click;
		tabc = new TabControl() {
			Location = new Point(50, 90),
			Size = new Size(300, 60),
		};
		Controls.AddRange(new Control[] {
			la0,
			bo0,
			btn1,
			tabc
		});
	}
	void btn1_Click(object sender, System.EventArgs e) {
		i++;
		TabPage tabp = new TabPage() {
			Text = "Page" + i.ToString(),
			Dock = DockStyle.Fill,
		};
		tabc.TabPages.Add(tabp);
		tabp.Controls.Add(new TextBox() {
			Text = bo0.Text,
			Dock = DockStyle.Fill,
			BackColor = Color.Azure,
		});
	}
	[STAThread]
	static void Main(string[] args) {
		Application.Run(new SampleForm());
	}
}





以上。

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?