Label / Form Resizing
-
I have built a custom message box form (Windows form), on this form I have a label which displays a message that gets passed in to the message box. My question is how can I resize the label and form based on the text passed in? if a large block of text is passed in, the form and label need to resize to be able to show all the text and not just cut it off. thanks for help
-
I have built a custom message box form (Windows form), on this form I have a label which displays a message that gets passed in to the message box. My question is how can I resize the label and form based on the text passed in? if a large block of text is passed in, the form and label need to resize to be able to show all the text and not just cut it off. thanks for help
Check out this for measuring a string (in pixels) http://msdn2.microsoft.com/en-us/library/403ezxd2(VS.80).aspx[^] Just use MeasureString on your string, and it will return the width and height of the text, which you can then use to resize your label and form. Hopefully ;)
My current favourite word is: Bacon!
-SK Genius
-
I have built a custom message box form (Windows form), on this form I have a label which displays a message that gets passed in to the message box. My question is how can I resize the label and form based on the text passed in? if a large block of text is passed in, the form and label need to resize to be able to show all the text and not just cut it off. thanks for help
Hi, set label.AutoSize true so the label grows and shrinks automatically, then set label.Text, now get label.Size and adapt form.Size accordingly. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.