
前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()

private void button1_Click(object sender, EventArgs e)
{
str = textBox1.Text;
Invalidate();
MessageBox.Show(str,"Button Click");
}
|
private Button button1;
private TextBox textBox1;
private string str = "Windows";
|
public MyForm()
{
InitializeComponent();
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));
}
|
![]()
| textBox1.KeyDown += new KeyEventHandler(textBox1_KeyDown); |
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{ if (e.KeyCode == Keys.Enter)
{ MessageBox.Show(textBox1.Text); }
}
|
![]()
![]()
![]()