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!
Try the Control.CreateGraphics method. The documentation says it's supported on the compact framework.
Graphics graphics = myLabel.CreateGraphics();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.