2

I have a user control that shows plate number of a vehicle(it contains a background image and some TextBoxes), I use DrawToBitmap() Method to get a bitmap of this control and show the bitmap on my form, It works fine on Windows 7 but in Windows XP service pack 3 only background image is drawn and texts in textboxes are not drawn, what should I do?

var clt = new ControlLisenceTouch();Bitmap b = new Bitmap(clt.Width, clt.Height);
clt.License = License.FromCar(someCar);
clt.Invalidate(true);
clt.DrawToBitmap(b, Rectangle.FromLTRB(0, 0, clt.Width, clt.Height));
pictureBox1.Image = b;
HPT
  • 351
  • 2
  • 11
  • I have had some similar weird behavior using this in Windows XP. I unfortunately found no fix for it :( – GETah Jun 05 '12 at 09:46
  • I'll put a buck on your UserControl actually containing a RichTextBox. Yes, not supported for that control. – Hans Passant Jun 05 '12 at 11:24
  • @HansPassant: NO, It just contains TextBox, no RichTextBox. I have the user control source code. – HPT Jun 05 '12 at 11:57

1 Answers1

0

This guy had the same sort of problem, and while the answer is not perfect, it did do it for him. The biggest problem here was that if another window was covering your control, that window would be shown as well. Look at my answer, the third edit shows taking a screen shot, and cropping a control out of it.

How can I get a screenshot of control? DrawToBitmap not working

According to http://msdn.microsoft.com/en-us/library/system.windows.forms.control.drawtobitmap.aspx
Windows XP sp3 is fully supported

Community
  • 1
  • 1
General Grey
  • 3,598
  • 2
  • 25
  • 32