概要
cscの作法、調べてみた。
練習問題やってみた。
練習問題
tabcontrolを、使え。
方針
- ToDoアプリを作る。
- 動的に、TabPageを作る。
写真
サンプルコード
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());
}
}
以上。
