我在这里的第一篇文章,所以这里是,
我有一个包含大约 30 个控件(标签、文本框等)的 UserControl。现在我想做一个“截图”。所以我使用了 UserControl 中的“DrawToBitmap”方法。
这里有一些示例代码
//this is the UserControl with the about 30 controls
var sampleusercontrol = new SampleUserControl();
var bmp = new Bitmap(sampleusercontrol.Width, sampleusercontrol.Height);
sampleusercontrol.DrawToBitmap(bmp, sampleusercontrol.Bounds);
如果我运行此代码,它会一直返回给我一个黑色图像。我不知道为什么。请帮忙!
编辑:
忘了说 UserControl 是 WinForms UserControl