code_junkie

Better Way of Manipulating RichText in C#?

Nov 11th, 2011
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. RichTextBox rtb = new RichTextBox();
  2. Font boldfont = new Font("Times New Roman", 10, FontStyle.Bold);
  3. rtb.Text = "sometext";
  4. rtb.SelectAll()
  5. rtb.SelectionFont = boldfont;
  6. rtb.SelectionIndent = 12;
  7.  
  8. public static void Set(this RichTextBox rtb, Font font, string text)
  9. {
  10.  
  11. rtb.Text = text;
  12. rtb.SelectAll();
  13. rtb.SelectionFont = font;
  14. rtb.SelectionIndent = 12;
  15. return rtb;
  16.  
  17. }
  18.  
  19. someRtb.Set(yourFont, "The Text").AndThenYouCanAddMoreAndCHainThem();
Add Comment
Please, Sign In to add comment