-5

I've a feedback message to get display in screen in my C# file. I stored the message in local constant string.
Have the requirement to bold few words in the message like below,

Important Notice : This feature is unavailable after 30-Oct. Please contact xyz@abc.com

Above message, "Important Notice" should be bold. Is there any way to design string like

private const string HelpText = "<b>Balloon</b> <br />A Balloon is the lump sum amount";

Edited : I'm using WinForms. On load message has to display

O. R. Mapper
  • 20,083
  • 9
  • 69
  • 114
Vino Spartan
  • 83
  • 2
  • 12
  • 8
    How is the string displayed? This will greatly depend on what UI toolkit you are using. – O. R. Mapper Aug 10 '15 at 07:14
  • 2
    Are you working in ASP .Net, Winform OR in WPF? – NASSER Aug 10 '15 at 07:15
  • 2
    You can store the string however you like. The problem will be will the UI component used *know* what to do with it. How are you displaying the string? – npinti Aug 10 '15 at 07:15
  • By the way, the `
    ` in your message suggests you also want to insert a linebreak. Your text does not say anything about that. While the solution will probably be generic enough to cover this, as well, you may want to make sure your example description and code match.
    – O. R. Mapper Aug 10 '15 at 07:16
  • also add static ==> private static const string HelpText – Nalaka Aug 10 '15 at 07:20
  • 3
    @Nalaka: Wrong. `const` already implies static. Cf. [the docs](https://msdn.microsoft.com/en-us/library/e6w8fe1b.aspx): "The **static** modifier is not allowed in a constant declaration." – O. R. Mapper Aug 10 '15 at 07:21
  • i've updated the question – Vino Spartan Aug 10 '15 at 07:24
  • @O.R.Mapper ==> thanks your correction :) – Nalaka Aug 10 '15 at 07:25
  • huh...no need of
    . its a typo....all i concern is Bolding string
    – Vino Spartan Aug 10 '15 at 07:26
  • This question is closely related to [this other question](http://stackoverflow.com/questions/11311/formatting-text-in-winform-label), and [this one](http://stackoverflow.com/questions/2063263/make-portion-of-a-labels-text-to-be-styled-bold) (the difference being that this question here does not require to do the formatting in a simple [`Label`](https://msdn.microsoft.com/en-us/library/system.windows.forms.label%28v=vs.110%29.aspx)). – O. R. Mapper Aug 10 '15 at 07:27
  • Your question is still too broad, please see [ask] – Sayse Aug 10 '15 at 07:31
  • @VinoSpartan: I think a piece of information you may be missing (to make your question more specific) is that WinForms does not come with any inherent formatting capabilities. That is, there is no specific syntax or otherwise marking that you could use to mark parts of your string as bold. What you will have to do is (unless you want to use any 3rd party tools) define and manually parse a custom syntax of markers that indicate which parts of the string are to appear in bold text, and then manually assemble several labels or similar with different font styles to achieve the desired effect. ... – O. R. Mapper Aug 10 '15 at 07:33
  • 1
    ... That is why @Sayse and others currently consider your question too broad. Essentially, any formatting is thinkable. You could scan the string for occurrences of `` and `` and use the substrings in between in bold labels, just as you've suggested yourself. Or you could scan for the first colon (`:`) and display evereything up to there in a bold label. etc. There are numberless valid solutions, and which one you choose depends entirely on your preference and possibly other requirements in your application that we cannot possibly know. – O. R. Mapper Aug 10 '15 at 07:36
  • @O.R.Mapper thnks fr your info n guide. I can't use 3rd parties. I could rather pick multi lables. – Vino Spartan Aug 10 '15 at 07:41

1 Answers1

0

It seems you want to show your string msg in specific custom format (bold, italic etc) in msgbox, Simplest way is You can create your own msgbox window form, and inside of that, you can use label control of winforms, to contain this string and then you can design the format of label control - Bold, Italic or any font changes.

Kunal Khatri
  • 451
  • 3
  • 12