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?
Asked
Active
Viewed 1,521 times
0
-
try `TableLayoutPanel` and add controls to it, and set it autosize, & Resize the Form on Textchange event of `Label` which is having ur message. – Javed Akram Aug 21 '14 at 14:15
-
@JavedAkram - resize the form again? I added the tabel layout and a label to the forst column and set that to autosize. Resize the form? – roopini n Aug 22 '14 at 03:37
-
Resize the form as `this.Size= new Size(tableLayoutPanel.Height + somevalue, tableLayoutPanel.Width + somevalue)` – Javed Akram Aug 22 '14 at 16:57
2 Answers
0
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 ..

Community
- 1
- 1

kishore V M
- 818
- 6
- 13
0
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