Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. private void richTextBox1_KeyPress(object sender, KeyPressEventArgs e)
  2. {
  3. if (e.KeyChar == (char)Keys.Enter)
  4. {
  5. //This is were the code should be
  6. }
  7. }
  8.  
  9. if (e.KeyChar == (char)Keys.Enter)
  10. {
  11. richTextBox1.AppendText("t");
  12.  
  13. // Edited After Comment
  14. var PrevLine = richTextBox2.Lines[richTextBox2.Lines.Count() - 1].ToString();
  15. var TabsCount = System.Text.RegularExpressions.Regex.Matches(PrevLine, "t").Count;
  16. }
  17.  
  18. if (e.KeyChar == (char)Keys.Enter)
  19. {
  20. richTextBox1.AppendText(Environment.NewLine);
  21. int prevLine = richTextBox1.GetLineFromCharIndex(richTextBox1.SelectionStart) - 1;
  22. MatchCollection mc = Regex.Matches(richTextBox2.Lines[prevLine], "s+");
  23. if (mc.Count > 0)
  24. richTextBox1.AppendText(mc[0].Value);
  25. e.Handled = true;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement