Windows Develop Bookmark and Share   
 index > Windows Forms General > Form resize depending on text size
 

Form resize depending on text size

Hi,

I have an small window (fixed size, with an OK button) to show messages to the user (with a label), some messages are short and others are large, sometimes the message is too large and just some part of the text is shown in the form, sometimes the message is to short that it does not look good to have a couple of words in the center of the form.

Is it possible to resize the form depending on the size of the text or label?

Thanks,

  • Moved byTaylorMichaelLMVPFriday, September 18, 2009 3:31 PMWinForms related (From:Visual C# General)
  •  
Kikeman  Friday, September 18, 2009 2:48 PM
A label, by default, automatically resizes itself based upon the content it contains.

A form, by default, does not autosize. Setting the Autosize property to true will cause the form to resize itself (larger only, by default) based upon the child controls it contains. However as you start to add controls that use docking, anchoring or autosize themselves then things start to look funny.

For your specific example of a messagebox-like dialog setting Autosize to true should be sufficient.

Michael Taylor - 9/18/09
http://p3net.mvps.org
  • Marked As Answer byKikeman Friday, September 18, 2009 3:42 PM
  •  
TaylorMichaelL  Friday, September 18, 2009 3:30 PM
A label, by default, automatically resizes itself based upon the content it contains.

A form, by default, does not autosize. Setting the Autosize property to true will cause the form to resize itself (larger only, by default) based upon the child controls it contains. However as you start to add controls that use docking, anchoring or autosize themselves then things start to look funny.

For your specific example of a messagebox-like dialog setting Autosize to true should be sufficient.

Michael Taylor - 9/18/09
http://p3net.mvps.org
  • Marked As Answer byKikeman Friday, September 18, 2009 3:42 PM
  •  
TaylorMichaelL  Friday, September 18, 2009 3:30 PM

You can use google to search for other answers

Custom Search

More Threads

• Why does it say I have a nullReference?
• How to change the mousepointer
• TreeView performance issue.
• How do you wire up custom MenuItem to Menu Classes
• Get theme progress color
• what the... Windows CE Forms app and pan & zoom
• Load a exe as a MDI child
• Problem with ContextMenuStrip size
• Saving Files From ListBox
• Changing DataMember shown in DataGridView