views:

232

answers:

1

Hello.

I trying to make a Control that inherits from System.Windows.Form.Label that can resize to fit its text.

I'm trying to override OnTextChanged method to use System.Drawing.Graphics.MeasureString to know the new size of the control, but I don't know how to obtain Graphics on OnTextChanged method?

Any advice?

Thank you!

+1  A: 

Try the Control.CreateGraphics method. The documentation says it's supported on the compact framework.

Graphics graphics = myLabel.CreateGraphics();
JaredPar
It throws a NotSupportedException. Maybe it doesn't implemented on .Net Compact Framework 2.0's label object.
VansFannel