これは私が持っているコードです:
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);