Not sure what "this" is in the context of your code, but ti's likely not an
object that supports CreateGraphics. I think the only items that support
CreateGraphics are Control, Panel, Form and PictureBox.
--
Chris Tacke, eMVP
Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net
"Christian Schwarz" <(E-Mail Removed)> wrote in message
news:bk9tp7$qtokm$(E-Mail Removed)...
> Hello,
>
> I get a NotSupportedException when using the following code snippet in the
> constructor of my ImageButton control:
>
> System.Drawing.Graphics gfx = this.CreateGraphics();
> SizeF textSizeF = gfx.MeasureString(this.Text, this.Font);
> this.m_TextSize = new Size((int)Math.Floor(textSizeF.Width),
> (int)Math.Floor(textSizeF.Height));
> gfx.Dispose();
>
> To be exact, the exception is thrown by the first line. Could anyone
explain
> why CreateGraphics() doesn't work here ?
>
> Christian
>
>