前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()
public MyForm()
{
InitializeComponent();
Paint += new PaintEventHandler(MyHandler);
}
|
private void MyHandler(object sender, PaintEventArgs e)
{
// pictureBox1.Image に新しい Bitmap を設定
pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height) ;
Graphics gra = Graphics.FromImage(pictureBox1.Image) ;
// フォント, ブラシの定義の定義
Font font = new Font("MS ゴシック", 7.8F);
SolidBrush brush = new SolidBrush(Color.Red);
// 文字列を描画する
for(int i=0; i<5; i++)
gra.DrawString("abcXYZ", font, brush, i*30, i*10);
}
|
![]()