Adding new line of data to TextBox

前端 未结 5 1333
一生所求
一生所求 2020-12-08 13:31

I\'m doing a chat client, and currently I have a button that will display data to a multi-line textbox when clicked. Is this the only way to add data to the multi-line textb

5条回答
  •  粉色の甜心
    2020-12-08 13:51

    Following are the ways

    1. From the code (the way you have mentioned) ->

      displayBox.Text += sent + "\r\n";
      

      or

      displayBox.Text += sent + Environment.NewLine;
      
    2. From the UI
      a) WPF

      Set TextWrapping="Wrap" and AcceptsReturn="True"   
      

      Press Enter key to the textbox and new line will be created

      b) Winform text box

      Set TextBox.MultiLine and TextBox.AcceptsReturn to true
      

提交回复
热议问题