/*************************************************************/
/*★ ボタンのクリックで TEXT を取得して表示する 前田 稔 ★*/
/*************************************************************/
using System;
using System.Drawing;
using System.Windows.Forms;
public class MyForm : Form
{
private Button button1;
private TextBox textBox1;
private string str = "C#";
public MyForm()
{
// textBox1
textBox1 = new TextBox();
textBox1.Parent = this;
textBox1.Location = new System.Drawing.Point(83, 205);
textBox1.Name = "textBox1";
textBox1.Size = new System.Drawing.Size(100, 19);
//this.textBox1.TabIndex = 0;
// button1
button1 = new Button();
button1.Parent = this;
button1.Location = new Point(94, 231);
button1.Text = "押す";
button1.BackColor = SystemColors.Control;
button1.Click += new System.EventHandler(this.button1_Click);
Paint += new PaintEventHandler(MyHandler);
}
private void MyHandler(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Font f = new Font("MS 明朝", 40);
g.DrawString(str, f, Brushes.Blue, new PointF(10F, 80F));
}
private void button1_Click(object sender, EventArgs e)
{
str = textBox1.Text;
Invalidate();
MessageBox.Show(str,"Button Click");
}
}
class form01
{
public static void Main()
{
MyForm mf = new MyForm();
Application.Run(mf);
}
}
|