I am creating a form in C# and need to display text on the form. I need some of the text to show up in a bulleted, unordered list. Is it possible to do this while using a label? Or a rich text box? I am not using ASP.NET and this is for a desktop app.
My message should look like this:
To continue please selected one of the actions below:
Thanks!
Just to add as a suggestion to the OP, I have found that using a StringBuilder
to construct multi-line messages helps me keep the formatting straight:
StringBuilder messageBuilder = new StringBuilder(200);
messageBuilder.Append("To continue, please select one of the actions below:");
messageBuilder.Append(Environment.NewLine);
messageBuilder.Append(Environment.NewLine);
messageBuilder.Append("\t\u2022 Click Button A to do this action.");
messageBuilder.Append(Environment.NewLine);
messageBuilder.Append("\t\u2022 Click Button B to do this action.");
MessageBox.Show(messageBuilder.ToString());
You can use ASCII or UniCode characters, and reformat your string to replace a marker character with the formatting character.
Say you defined your string like so:
var myMessage = "To continue please selected one of the actions below: * Click ButtonA to do this action. * Click ButtonB to do this action."
you could do a Regex.Replace that looked for asterisks and converted to bullets:
var formattedString = Regex.Replace(myMessage, "\*", "\r\n \u2022");
Since the string was defined on one line, we also put in a newline ("\r\n").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With