Assuming you are using a
System.Windows.Forms.MessageBox[
^] (you did not stated which project type):
It is not possible to format the text of a
MessageBox
. You cannot have bold, italic, etc... format specifiers. And it will not recognize HTML format, either.
There are solutions, but that implies that
- either you find an article in which someone already did the job; for example there is one here on CP:
FlexibleMessageBox – A flexible replacement for the .NET MessageBox[
^]
There can be others, though. You can have a Google search for "c# winforms formatted messagebox" for example.
- or you implement your own message box by subclassing the
Form
class.
public class FormattedMessageBox : Form
{
}
Moreover, I would like to say that, even if it was possible to format a Windows Forms MessageBox with some HTML code, as you tried to do, the result which you would have produced would not have been valid html code. Here is what the string you are building would resort to:
<html>
<body>
<p>Hello how are you doing? <FINE/NOTWELL>
<p></br>
</body>
</html>
Line 3: you cannot write a
<
or
>
character in a HTML string, because these characters are used by HTML parsers to identy the tags of the document. Thus,
<FINE/NOTWELL>
would be interpreted as a HTML tag; an invalid one. To write
<
and
>
in a HTML document, you have to use
<
and
>
, respectively.
Maybe that could help you understand HTML entities:
HTML Entities - w3schools[
^]
Line 3: an opening
<p>
tag need its closing
</p>
counterpart.
Line 4: same remark as above.