I have a PictureBox on the Form. The Graphic object is getting from that PictureBox for drawing. I drew a string. Ran fine in emulator. However, when ran in device with pocket pc platform, I got exception. There is no specific error. How come
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim grpDraw As Graphics = PictureBox1.CreateGraphics()
grpDraw.DrawString("123",
New Font("Courier New", 8.25, FontStyle.Regular), New SolidBrush(Color.Black), 5, 5) End Sub
When I clicked on the button in pocket pc device. I got an exception of NotSupportedException. I have .Net Compact 2.0.
There is something very wrong in your description. As far as I know, PcitureBox.CreateGraphics is not supported so I am having trouble accepting your assertion that this code works in the emulator; can you try that again please
If you insist that it works in the emulator then I'd check that the PPC you are using is 2003 and above since CF 2.0 is not supported on earlier versions (2000 or 2002). It also helps to use breakpoints so you can tell the forum exactly which statement causes the exception.
I suspect you'll find this code doesn't work anywhere. If you change the first statement to use Me.CreateGraphics then it will work but your "123" text will be drawn on the form, not the picturebox.
To draw on the picturebox, handle its Paint event and put the code in there; again change the first statement to be grpDraw = e.Graphics
DrawString to PictureBox Got Exception VB.Net
mcalvin
grpDraw.DrawString("123",
New Font("Courier New", 8.25, FontStyle.Regular), New SolidBrush(Color.Black), 5, 5) End SubWhen I clicked on the button in pocket pc device. I got an exception of NotSupportedException. I have .Net Compact 2.0.
Quattrus
---
Mark Arteaga
.NET Compact Framework MVP
http://www.neotericsdc.com | http://blog.markarteaga.com
WilsonC
There is something very wrong in your description. As far as I know, PcitureBox.CreateGraphics is not supported so I am having trouble accepting your assertion that this code works in the emulator; can you try that again please
If you insist that it works in the emulator then I'd check that the PPC you are using is 2003 and above since CF 2.0 is not supported on earlier versions (2000 or 2002). It also helps to use breakpoints so you can tell the forum exactly which statement causes the exception.
I suspect you'll find this code doesn't work anywhere. If you change the first statement to use Me.CreateGraphics then it will work but your "123" text will be drawn on the form, not the picturebox.
To draw on the picturebox, handle its Paint event and put the code in there; again change the first statement to be grpDraw = e.Graphics
Good luck!
Cheers
Daniel