Visual Basic richtextbox - setting specific text to Italic font style

后端 未结 3 1972
庸人自扰
庸人自扰 2021-01-25 09:56

I have created a Richtextbox, which produces text based on user-inputted variables as well as some basic formatting - eg:

name = txtname.text
richtextbox1.text =         


        
3条回答
  •  别那么骄傲
    2021-01-25 10:38

    Try this:

    Me.RichTextBox1.Rtf = "{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}} hello my name is \i Bob\i0 \par}"
    

    If you use wordpad to write some sample text, save it in rtf format and then open the file in notepad, you will get something to start with. You can remove some of what wordpad adds (like the program that generated it) but it looks like you have to leave in at least the code page and at least one font.

提交回复
热议问题