0

これは私が持っているコードです:

Button b = new Button();
Graphics g = b.CreateGraphics();

g.DrawString("Hello World", new Font(FontFamily.GenericSerif, 5), Brushes.Red, new PointF(1, 1));

b.Height = 100;
b.Width = 100;

this.Controls.Add(b);

私はボタンを取得しますが、その上に画像はありません..

私は必要なことを行う次のコードを使用しています。みんな、ありがとう。

Button b = new Button();
b.Height = 100;
b.Width = 100;

Bitmap bitmap = new Bitmap(b.Height, b.Width);
Graphics g = Graphics.FromImage(bitmap);
g.DrawString("Hello World", new Font(FontFamily.GenericSerif, 5), Brushes.Red, new PointF(1, 1));

b.Image = bitmap;
this.Controls.Add(b);
4

1 に答える 1

0

Button Image プロパティを使用して、ボタンにイメージを設定します。

 Button b = new Button();
 Bitmap picture = new Bitmap();
 b.Image = picture;
于 2012-08-16T11:39:04.953 に答える