Add text bullets to a C# form

后端 未结 5 2142
無奈伤痛
無奈伤痛 2021-02-08 17:54

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?

5条回答
  •  醉梦人生
    2021-02-08 18:29

    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").

提交回复
热议问题