Advertisement
bobmarley12345

textbox textwriter impl

Nov 22nd, 2021
1,339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. public class TextBoxTextWritter : TextWriter {
  2.     public override Encoding Encoding => Encoding.Unicode;
  3.  
  4.     private TextBox textBox;
  5.     public TextBox TextBox { get => this.textBox; }
  6.  
  7.     public TextBoxTextWritter(TextBox box) {
  8.         this.textBox = box;
  9.     }
  10.  
  11.     public override void Write(char value) {
  12.         this.textBox.Text += value;
  13.     }
  14.  
  15.     public override void Write(char[] buffer, int index, int count) {
  16.         this.textBox.Text += new StringBuilder(count - index).Append(buffer, index, count).ToString();
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement