I have a windows application where I have created a custom form with text, name , caption and error icon. But what happens is that if the number of characters exceed, then the text doesn't fit the message box and the button position changes automatically and takes the other position and looks unaligned. I tried all the form properties like Dock,Anchor style, AutoSize but nothing helped. How can I do this?
Check if wrapping the text ( in the label ) will meet the purpouse. Following is the link how to wrap the text inside the label. please Check the completed thread on this link. Hope this helps ..
If you are finding a dynamically sized MessageBox , check this:
First, I assume your MessageBox is dynamically created.
I suggest you do the following to auto-size your MessageBox:
// in the constructor of you dialog box
public YourDialog()
{
InitializeComponent();
// here contentLabel contains the content you gonna display, and SHOULD be
// set before this dialog is constructed
Width = Math.Max(contentLabel.Width + 2*contentLabel.Location.X, ClientSize.Width);
}
If you are looking for a label that allows you to do auto wrapping , check this post as suggested by @kishoreVM: Word wrap for a label in Windows Forms
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.