A simple question:
I have to put a string into a label control.
From a cs file how can I resize the width of the label control according to the string's lenght?
Thanks in advance
Printable View
A simple question:
I have to put a string into a label control.
From a cs file how can I resize the width of the label control according to the string's lenght?
Thanks in advance
I believe you can just set the label's AutoSize attribute to true, and it'll autosize automatically. I can't test it right now, but I'm fairly confident it works.
Graphics.MeasureString will do the job.
Inherit from Label, Override the OnPaint method and you have e.Graphics in the EventArgs.