How To Format Part Of a String?

Say I have a string who's text is "Only the word 'bold' is bold." Is there a way to format the string like this so that only the word 'bold' is bold

Basically, I want to add to my program a feature similar to intellisense, which shows you the required part of a piece of code in bold when you go to type it.

Thanks for any help.



Answer this question

How To Format Part Of a String?

  • bagjuice

    unfortunately not, you can do it using an RTB control but to actually format a string variable - not possible AFAIK.

    if you are using the RTB control then yes it's possible, simply when "bold" comes across in the text, select that word and just make the Font bold using:

    Dim theFont as new Font(Me.Font, FontStyle.Bold)

    however I am unsure how to actually make that selected text bold properly in the RTB control but do hope that this small information helps you in some way.

    It can be done, no doubt and the code makes the font bold but now its actually applying it....I will investigate further but I'm also sure other people will have a solution



  • ThE_lOtUs

    Use a RichTextbox control - textbox control does not support partial text formatting.

    This allows you to adjust the formatting of the text (Font Formatting, Textcolor etc. sizing etc.)- whereas the standard textbox control is much more limited.

    You can do a simple web search on VB.NET + Richtextbox + Formatting

    http://www.google.com/search hl=en&q=vb.net+%2B+richtextbox+control+%2B+formatting

    and this will reveal numerous URL's with information on


  • AzenAlex

    Thanks for your reply. Sorry I worded the question wrong, I meant to say is there a way to format only part of the text in a label, textbox, ect. in code.


  • How To Format Part Of a String?