I am looking for a way to have some control over the shape of a simple MessageBox in Winforms. I would like to control where the passed in text wraps so that the dialog rect is narrower. Windows seems to want to make the dialog as wide as possible before wrapping the text. Is there an easy way to control the maximum width of the dialog without resorting to creating my own custom form?
+1
A:
You can embed newlines in the text to force it to wrap at a certain point. e.g.
"message text...\nmore text..."
update: I posted that thinking it was a win32 API question, but I think the principle should still apply. I assume WinForms eventually calls MessageBox().
Ferruccio
2008-09-19 15:08:44
This should be Environment.Newline rather than \n
Brann
2009-04-08 08:26:26
A:
What happens if you throw your own newlines in the string message you pass it? I'm pretty sure that will work if I recall correctly.
whatsisname
2008-09-19 15:09:10
+1
A:
There's really just two ways (sane ways)
1) Add line breaks to your string yourself to limit the lenghth of each line.
2) Make your own form and use it rather than messagebox.
Philip Rieck
2008-09-19 15:09:46