How to set RichTextBox Font for the next text to be written?

后端 未结 3 2254
耶瑟儿~
耶瑟儿~ 2020-12-10 03:58

I need to set the font family for the next text to be written in a RichTextBox. I tried setting that with...



        
3条回答
  •  遥遥无期
    2020-12-10 04:47

    This isn't exactly a trivial answer.

    To do inline text formatting in a Rich TextBox like you want you will have to modify the Document property of the RichTextBox. Very simply, something like this will work

    
      
        
          
            Something
            Something Else
          
        
      
      
    

    I think you could create a custom Control that creates a new block element and sets the font properties you need based on the user input.

    For example, If the user types something then presses bold. You would want to wrap the previous text in a run and create a new run element setting the FontWeight to bold then the subsequent text will be wrapped in the bolded run.

    Again, not a trivial solution but I can't think of any other way to accomplish what you are after.

提交回复
热议问题