Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.Text.RegularExpressions;
- using System.Windows.Forms;
- namespace GiddleTest1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void rtbText_TextChanged(object sender, EventArgs e)
- {
- string[] befehle =
- {
- "IF", "THEN", "ELSE", "ENDIF" // Befehle vervollständigen...
- };
- string pattern = String.Join("|", befehle);
- Regex R = new Regex(pattern);
- int index = rtbText.SelectionStart;
- rtbText.SuspendLayout();
- foreach (Match m in R.Matches(rtbText.Text))
- {
- rtbText.SelectionStart = m.Index;
- rtbText.SelectionLength = m.Length;
- rtbText.SelectionColor = Color.Blue;
- rtbText.SelectionStart = index;
- }
- rtbText.SelectionColor = Color.Black;
- rtbText.ResumeLayout(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement