textbox text color change

后端 未结 3 1785
鱼传尺愫
鱼传尺愫 2021-01-05 12:58

I have textbox textbox1 and I want to change text color, but in the part of all text. For example from /* to */ like comm

3条回答
  •  一个人的身影
    2021-01-05 13:49

    You will have to derive a control from TextBox and put in code that will either allow the user to change the colour or changes the colour based on your rules.

    A RichTextBox will give you the basis for this as it allows different "runs" of text each of which can have it's own styling:

    
      
        
          Paragraph 1
        
        
          Paragraph 2
        
        
          Paragraph 3
        
      
    
    

    If you add controls for colour etc. then you can create a new run from the user's selection with the required style.

提交回复
热议问题